If ptr is an integer pointer, writeC++ statement to allocate memoryfor an integer number and initialise it with 12.
Answers
Answered by
0
Answer:
Here is a short program to demonstrate it :
int main() {
int *p = new int;
*p = 12;
cout<<*p<<endl;
}
Output : 12
Explanation:
The pointer variable p is stored on the stack memory and the int it points to (which is nothing but the address of allocated memory) is stored on heap memory.
Similar questions