Question

[8] What do the following pairs of statements in C++ accomplish, or display? Explain your solution. int *p, k; k 25; p = new int; p = &k; cout << p << endl
0 0
Add a comment Improve this question Transcribed image text
Answer #1

output: 25

Explanation:

int *p,k; // declaration p as a pointer and k as an integer
k=25; // k vlaue is 25
p =new int; //allocating the memory for pointer p.
p=&k; // the address of k is assigned to p
cout<<*p<<endl; //*p displays the value located in the address its points.

// p has the address of k , where k value is 25, so the pointer p points to the value 25.

// so it display the value 25 as output.

//any clarification please comment..

Add a comment
Know the answer?
Add Answer to:
What do the following pairs of statements in C++ accomplish, or display? Explain your solution. int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT