Answer the following questions:
a) Explain the differences between float x; and float* ptrx;
b) Show the output from the following program. If an unknown value gets printed, write U.
int main()
{
int m, n;
int* p = &m;
int* q;
*p = 35;
cout << *p << ' ' << *q << endl;
q = &n;
n = 50;
cout << *p << ' ' << *q << endl;
p = &n;
*p = 10;
cout << *p << ' ' << n << endl;
return 0;
}
c) Declare a pointer variable q and initialize it to point to the first element of an int array named arr. Use the pointer variable to print
out the elements of the array arr.
d) Draw the memory map of the following code sequence:
double u, x(20.5); //assume the address of y is 10
double *a = &x; //assume the address of x is 14
y = *a;
e) Answer the questions given at the bottom of this code sequence:
int x, y;
int *p1, *p2;
x = 6;
p1 = &x
y = *p1/2 + 10;
p2 = p1;
What is the value of x? ___
What is the value of y? ___
What is the value of *p1? ___
What is the value of *p2? ___
f) What is the value of using new and delete in C++?