Question
A pointer is a special-type of variable that points to a stored variable. It does so by storing the address of the variable being pointed
A pointer is a special-type of variable that points to a stored variable. It does so by storing the address of the variable being pointed at. In this program, we will learn working with pointers and dynamic memory. In your main function: Declare an integer my_int initialized with value 10 Declare two integer pointer variables my_iptr and my_iptr2 Assign the address of my_int variable to the pointer my_iptr. Display the following on the screen: o The value of the variable using the variable name o The address of the variable using the variable name o The address of the variable using the pointer o The value of the variable using the pointer Using the pointer my_iptr, update stored integer value from 10 to 15. Display the value of the integer using the variable name Did the value of my_int change to 15? Think why, it did or did not change. Now we will use new and delete to implement dynamic memory in the program. Add the following functionalities in your code. Update your integer pointer my_iptr by allocating new memory to it. Using the pointer variable, assign a value of 20 to it. Display the value of my_int using the variable name Did the value of my_int change to 20? Think why, it did or did not change. Using new, allocate dynamic memory to my_iptr2. Assign my_iptr to my_iptr2. Dereference my_iptr2 to display the value it is pointing at. Delete both pointers. Complete the requested changes,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started