Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program Use typdef to create a type that declares integer pointers. CHAPTER

ID: 3810192 • Letter: C

Question

C++ Program

Use typdef to create a type that declares integer pointers.

CHAPTER 10 Pointers and Dynamic Arrays Display 10.2 Basic Pointer Manipulations Program to demonstrate pointers and dynamic variables 1 2 include Kiostream> 3 using namespace std 4 int main int *pl, *p2 1 new int *pl 42 p2 pl *pl endl. i 10 cout pl *p2 endl *p2 cout 53 *p2 cout *pl *pl endl 13 *p2 endl p2 cout pl new int 15 *pl 16 cout pl *pl endli cout *p2 *p2 endl cout "Hope you got the point of this example In return 0 21 Sample Dialogue Hope you got the point of this example

Explanation / Answer

A pointer is nothing it hold value and address of variable

*variable name hold the the value

variable name hold the the address

Here we have two variable p1 and p2

*p1 = 42 = > p1 holds value of 42

later p2 = p1 // the address of p1 is assigned to p2

so what ever the value of p1 it is been assigned to p2, If any value changes in p1 that will reflect to p2

It prints out

*p1 = 42

*p2 = 42

*p1 = 53 = > p1 holds value of 53

also the value of *p2 is changed to 53

It prints out

*p1 = 53

*p2 = 53

p1 = new int

where a new adress is created to p1 , p2 remains the same address

*p1 = 88 = > p1 holds value of 83

the value of *p2 remains to 53

It prints out

*p1 = 88

*p2 = 53

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote