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

3. For each of the following lines of variable declarations, identify it as vali

ID: 3627225 • Letter: 3

Question


3. For each of the following lines of variable declarations, identify it as valid or describe what makes the line invalid.

Line 1: n = 12;
Line 2: char letter = ;
Line 3: int two;
Line 4: double x, y, z;

4. Write C++ statements that accomplish each of the following:

a. Declare and initialize int variables x to 25 and y to 18.
b. Declare and initialize an int variable temp to 10 and a char variable ch to 'A'.
c. Add 5 to the int variable x which already exists.
d. Declare and initialize a double variable payRate to 12.50.
e. Copy the value from an existing int variable firstNum into an existing int variable tempNum.
f. Swap the contents of existing int variables x and y. (Declare any new variables you need.)
g. Output the contents of existing double variables x and y, and also output the value of the expression x + 12 / y - 8.
h. Copy the value of an existing double variable z into an existing int variable x.

5. Given the following variable declarations:

int x = 2, y = 5, z = 6;

What is the output from each of the following statements?

a. cout << "x = " << x << ", y = " << y << ", z = " << z << endl;
b. cout << "x + y = " << x + y << endl;
c. cout << "Sum of " << x << " and " << z << " is " << x + z << endl;
d. cout << "z / x = " << z / x << endl;
e. cout << "2 times " << x << " = " << 2 * x << endl;

6. Given the following variable declarations:

int a = 5, b = 6, c;

What is the value of a, b, and c after each of the following statements executes? Assume that the statements execute in the sequence given.

a. a = b++ + 3;
b. c = 2 * a + ++b;
c. b = 2 * ++c - a++;




Explanation / Answer

DEAR FRIEND here is the answer for your questions PLEASE RATE --------------------------------------------------------------- (3) Line 1: n = 12; // u didn`t spicfy the type of the variabls so invalid Line 2: char letter = ; invalid there is no value given after = Line 3: int two;//valid Line 4: double x, y, z;//valid --------------------------------------------------------------- (4) a) int x=25, y= 18; b) int temp=10; char ch='A'; c) x=x+5; d) double payRate=12.5; e) tempNum = firstNum ; f) int z; z=y; y=x; x=z; g) cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote