C++ C++ Given the following memory model, write the code that: o. (1 pt)Write th
ID: 642072 • Letter: C
Question
C++
C++ Given the following memory model, write the code that: o. (1 pt)Write the code that would have created the array (called x) of 5 ints (assume it gets placed in memory as shown (along the first row)) p. (2 pts) Write the code that prints out the address of the first value in the array q. (2 pts) Write the code that prints out the address of the third value in the array r. (2 pts) Write the code that creates this variable (called y) (aka a pointer): s. (2 pts) Write code that uses the variable y to print out the value 4 t. (2 pts) Write code using the variable y to print out 0x28fedc u. (2 pts) Write code using the variable y to print out 0x37232a y. (1 pt) Create a new variable (z) that holds 72 (assume it gets placed in memory as shown) w. (2 pts) Change the variable y so that it points to z (holds the address of z).Explanation / Answer
o. (1 pt) Write the code that would have created array (called x) of 5 ints
int x[5] = {3,4,7,1,5};
p. (2pts) Write the coe that prints out the address of first value in the array;
cout << x ;
q. (2pts) Write the coe that prints out the address of third value in the array;
cout <<(x+2);
r. Write the code that creates this variable y (aka pointer);
int* y = &x[0];
s. Write the code that uses variable y to print out the value 4.
cout << *(y+1);
t. Write the code that users variable y to print out 0x28fedc
cout << y;
u. Write the code that users variable y to print out 0x37232a
cout << &y ;
v. Create new variable z that holds 72
int z = 72;
w. Change the variable y so that it points to z. (holds the address of z);
y = &z;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.