What is the output of this code ?
What does the following code snippet do?
The code snippet initializes an integer variable, assigns a value to it indirectly using a pointer, and then prints the value using pointer manipulation.
Code Explanation:
int number; - declares an integer variable named number.
int *ptrNumber = &number; - declares a pointer variable named ptrNumber and assigns it the memory address of number using the address-of operator (&).
*ptrNumber = 1001; - assigns the value 1001 to the memory location pointed to by ptrNumber using the dereference operator (*).
cout << *&*ptrNumber << endl; - prints the value at the memory location pointed to by ptrNumber using pointer manipulation.
Since the value at that memory location is 1001, the output will be "1001".