int x; int* intPtr;   Write a C++ program that contains five more statements. The first statement makes intPtr point to x by using the address-of operator.  The second statement dereferences intPtr and stores the value 5 into x via indirect addressing. The third statement prints the actual memory address of where the variable x is stored. The fourth prints the contents of intPtr. The fifth prints the contents of x. Show your source code and program output.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter12: Points, Classes, Virtual Functions And Abstract Classes
Section: Chapter Questions
Problem 1TF
icon
Related questions
Question

int x;

int* intPtr;

 

Write a C++ program that contains five more statements. The first statement makes intPtr point to x by using the address-of operator.  The second statement dereferences intPtr and stores the value 5 into x via indirect addressing. The third statement prints the actual memory address of where the variable x is stored. The fourth prints the contents of intPtr. The fifth prints the contents of x. Show your source code and program output.

Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning