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

4. Using cin, Allocating Memory, and Writing Assignment Statements cin, Memory A

ID: 3888566 • Letter: 4

Question

4. Using cin, Allocating Memory, and Writing Assignment Statements cin, Memory Allocation, and Assignment Statements Show the variable name and value of each statement

1.double x;
cin >> x;
//Assume the user enters 3.24.

2.double a, b, c = 0.0;

3.int d = 2, x = 3, y = 4;
4 = d – x + y;

4.double def = 123.5; int y;
y = def;

5.int b = 9.0;

6.int num1= 8, num2 = 3, temp = 0;
temp = num1;
num1 = num2;
num2 = temp;

7.int num;
cin >> num;
//Assume the user enters 8.
num++;

8.int c = 8;
++c;
c--;

9.double x = 5.0;
int y = 4;
x = x + y / 4;

10.double x = 5.0;
int y = 4;
y = x + y/4;

11.      int count = 0;
      cout << ++count << endl;
      cout << count++ << endl;
      cout << count << endl;

1.double x;
cin >> x;
//Assume the user enters 3.24.

2.double a, b, c = 0.0;

3.int d = 2, x = 3, y = 4;
4 = d – x + y;

4.double def = 123.5; int y;
y = def;

5.int b = 9.0;

6.int num1= 8, num2 = 3, temp = 0;
temp = num1;
num1 = num2;
num2 = temp;

7.int num;
cin >> num;
//Assume the user enters 8.
num++;

8.int c = 8;
++c;
c--;

9.double x = 5.0;
int y = 4;
x = x + y / 4;

10.double x = 5.0;
int y = 4;
y = x + y/4;

11.      int count = 0;
      cout << ++count << endl;
      cout << count++ << endl;
      cout << count << endl;

Explanation / Answer

1) finally x = 3.24 as per user input

2) value of c = 0.0

variables "a" & "b" have some address assigned as they are not yet initialized with some values

3) in statement 1,

variable x = 3 variable y = 4 variable d = 2

Statement 2 has invalid syntax

4) value of y = 123, value of def =123.5

value of variable def is downcasted from double to integer and finally stored in variable "y"

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