Assume that x is at memory location 0x61fe18, and xptr is at memory location 0x61fe10.
What is printed by the below snippet of code?
int x; int * xptr; xptr = & x; x = 12; cout << x << endl; cout << xptr << endl; cout << &x << endl; cout << &xptr << endl; cout << *xptr << endl;
cout << x << endl; this will print 12 the value of x
cout << xptr << endl; this will print 0x61fe18 the memory address of x
cout << &x << endl; this will also print 0x61fe18 the memory address of x
cout << &xptr << endl; this will print 0x61fe10 the memory address of xptr
cout << *xptr << endl; this will print 12 the value stored at memory address 0x61fe18 ( of x)
So the output will look like
12
0x61fe18
0x61fe18
0x61fe10
12
Thanks.
Get Answers For Free
Most questions answered within 1 hours.