Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6.Write C++ statements that accomplish the following:a) Output the newline chara

ID: 3855296 • Letter: 6

Question

6.Write C++ statements that accomplish the following:a) Output the newline character.b) Output the tab character.c) Output double quotation mark.

7.Give meaningful identifiers for the following variables:a) A variable to store the first name of a student.b) A variable to store the discounted price of an item.c) A variable to store the number of juice bottles.d) A variable to store the number of miles traveled.e) A variable to store the highest test score.

8.Write C++ statements to do the following:a) Declare int variable num1 and num2.b) Prompt the user to input two numbers.c) Assign the first input number to num1 and the second input number to num2d) Output num1, num2, and 2 times (num1 minus num2). Your output must identify each variable name followed by its value, then the expression for 2 times (num1 minus num2) followed by its value.

9.Suppose a, b, and c are int variables and it each case the program begins with a = 5, b = 6, and c is undefined. What value is assigned to each variable after each statement executes? If a variable is undefined at a particular statement, report UND(undefined).

Case 1: a = (b++) + 3; //a = , b = , c =

Case 2: c = 2 * a + (++b); //a = , b = , c =

Case 3: b = 2 * (++c) - (a++); //a = , b = , c =

10.What is printed by the following program? Suppose the input is as follows:

Miller34340

#include <iostream>#include <string>

using namespace std;

const int PRIME_NUM = 11;

int main () {

const int SECRET = 17;string name;int id;int num;int mysteryNum;cout << "Enter last name: ";cin >> name;cout << endl;cout << "Enter a two digit number: ";cin >> num;cout << endl;id = 100 * num + SECRET;cout << "Enter a positive integer less than 1000: ";cin >> num;cout << endl;mysteryNum = num * PRIME_NUM - 3 * SECRET;cout << "Name: " << name << endl;cout << "Id: " << id << endl;cout << "Mystery number: " << mysteryNum << endl;

return 0;

}

Explanation / Answer

6.

a ) cout<<" ";

b ) cout<<"\t ";

c ) cout<<"" ";

7.

a ) string firstName;

b ) double discount;

c ) int bottleCount;

d ) int miles;

e ) int highestScore;

NOTE: Please note that the bold underlined parts above are the name of the identifiers which is only asked in your question. However, I have mentioned their data types too in case if you need it. If you need only the identifier names then remove the data types e.g., string firstName will change to firstName and so the remaining ones.

8.

a )

// declaring num1, num2

int num1;
int num2;

b )

// Prompting the user to input two numbers

cout << "Input two numbers: ";

c )

// Assigning input numbers to the num1 and num2
cin >> num1>>num2;

d )

// output the values of num1, num2 and expression

cout << "num1 = "<<num1<<endl;
cout << "num2 = "<<num2<<endl;
cout << "2*(num1 - num2) = "<< ( 2 * (num1 - num2));

9 .

Case 1: a = 9, b = 7, c = UND // b will increment to 1, c will be undefined because it is uninitialized, a will be

// assigned with the value of expression i.e., 9 since b has postfix increment hence increment of b will take place

// only after evaluating the expression.

Case 2: a = 9, b = 8, c = 26 // here b has prefix increment so, first value of b will be increment from 7 to 8 then the

// expression will be evaluated and final value will be assigned to c. => 2*9 + (7 + 1) = 18 + 8 = 26

Case 3: a = 10, b = 45, c = 27 // understand this part by yourself based on above explanations.

10.

Name: Miller

Id: 3417

Mystery Number: 3689

Explanation:

id is calculated from the following expression

id = 100 * num + SECRET;

So num is 34 and SECRET = 17

Hence, id = 100 * 34 + 17 => 3400 + 17 = 3417

Mystery Number is calculated from the following expression.

mysteryNum = num * PRIME_NUM - 3 * SECRET;

=> 340 * 11 - 3 * 17 // since num is inputted again as 340

=> 3740 - 51

= 3689