Concept explainers
Which of the following preprocessor directive is correct?
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Introduction to Programming with C++
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Absolute Java (6th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Starting Out with Programming Logic and Design (4th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
C How to Program (8th Edition)
- To use dynamic memory allocation functions, which of the following header files must be included?a) stdlib.hb) stdio.hc) memory.hd) dos.harrow_forwardAfter working this code, this is the error code that popped up resulted in half right. Traceback (most recent call last): File "main.py", line 292, in <module> print(double_pennies(starting_pennies, user_days)) File "main.py", line 264, in double_pennies total_pennies = double_pennies((num_pennies * 2), (num_days - 1)) File "main.py", line 264, in double_pennies total_pennies = double_pennies((num_pennies * 2), (num_days - 1)) File "main.py", line 264, in double_pennies total_pennies = double_pennies((num_pennies * 2), (num_days - 1)) [Previous line repeated 995 more times] File "main.py", line 260, in double_pennies if num_days == 1: RecursionError: maximum recursion depth exceeded in comparisonarrow_forwardPYTHON3 Complete the given function, encrypt_text that encrypts the variable text using the provided key by applying a modified version of Caesar’s Cipher with the following rules: The key will contain a word made up of the letters ‘u’ and ‘d’. The cipher will use the key to determine the direction of the shift, with a ‘u’ indicating that the character must be shifted upwards while a ‘d’ indicating a downward shift. The number of characters in the key will determine the number of positions to shift. The given text variable will only contain characters from the ASCII table with values between 32 and 126. If the key is invalid (empty string, contains characters other than u and d) or the text is invalid (empty string), no encryption occurs and the function returns the original text. If the text has more characters than the key, the key will loop through again to accommodate the additional text characters. An iterative approach should be used to solve this problem. Brute force…arrow_forward
- Need to create two MIPS functions: one that emulates DIV and one that emulates DIVU. I CANNOT USE DIV OR DIVU. It only takes the divisor and the dividend as arguments, so no need to load anything.arrow_forwardComplete the following sentences by filling the right word To check if two string variables string1 and string2 refer to the same memory address we use the command ………arrow_forwardHere are the code and output, can you please help me answer the two questions? code: #include<iostream>#include<time.h>using namespace std; // tower of HANOI function implementationvoid moveDisk(int n, char Original, char Aux, char Dest){if(n == 0)return;moveDisk(n-1, Original, Dest, Aux);cout << "Move Disk " << n << " from " << Original << " to " << Dest << endl;moveDisk(n-1, Aux, Original, Dest);} // main programint main(){int n;time_t start, end; cout << "Enter the number of disks:";cin >> n; // calling the moveDisktime (&start);moveDisk(n, 'A', 'B', 'C');time (&end); double elapse = difftime (end, start);cout << "The elapsed time is " << elapse << " seconds" << " for moving " << n << " disks " << endl; return 0;} output: 1.How many seconds does the server spend on 16 disks? 2. How many disks can successfully move from A to C, in 24-hour?(please list a brief…arrow_forward
- Which of the following is not a reserved word in C++? (1) int include double const cin boolarrow_forwardWhat does function sqrt do? Which header file must be included to use the function sqrt? (3)arrow_forwardThis specific file includes the declarations of the basic standard input and output operations in C++. dos.h iostream.h math.h conio.h Which of the following user-defined identifiers is valid in C++? Name n@me all of the above #namearrow_forward
- Which of following will add 3 bytes at where the operation is specified and initialize it to "Hi" with a null terminated character appended to it? msg: .STRING "Hi\x00" msg: .ASCII "Hi\x00" .WORD "Hi\x00" msg: .ASCII "Hi" Which of following function declaration makes a double parameter x to be passed-by-reference? A. void func(double *x); B. void func(double x*); C. void func(double x&); D. void func(double& x);arrow_forwardIn Python, Use the file scores.txt (below) to help with the coding problem.! scores.txt ——————— John -3 Paul 3 Sue 2 ——————- utilize the follow function headers: Main() WriteScores() ReadScores() First, the main function will ask the user, “do you want to record scores or read scores?” Depending on what the user inputs, the answer will determine whether to call WriteScores OR ReadScores. The WriteScores function will then ask the user, “how many scores do you want to add?”. The function will then read each of the players name and score as keyboard input, then save these as records in a file named scores.txt. Sample output: Do you want to read scores or write scores? Type r or w: r Name: John Golf Score: -2 Name: Paul Golf Score: -1 Name: George Golf Score: - 4arrow_forwardThe code that I have written is provided down below i just need help revising it when i run it i only get 20/100. The instructions are down below and what it is supposed to look like. The code has different functions which is provided down below can you help please fix it and show the output. Main.cpp #include "Triangle.h"#include "Square.h"#include <iostream> using namespace std; int main() { //Do not modify Triangle t; Square s; cin >> t; t.calculateArea(); cout << t; cin >> s; s.calculateArea(); cout << s; return 0;} ---- Sqaure.cpp #include "Square.h"#include <iostream>using namespace std; Square::Square(){ base = 0; height = 0;} Square::Square(int b, int h) : base(b), height(h) { } void Square::setBase(int b){ base = b;} void Square::setHeight(int h){ height = h;} void Square::calculateArea(){ // calculate Area correctly depending on shape type area = base * height;} int Square::getBase() const{ return…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning