Question

The following statements are in C++: 1. Consider the following statements: int *p; int i, k;...

The following statements are in C++:

1. Consider the following statements:

int *p;

int i, k;

i = 50;

k = i;

p = &i;

After these statements, which of the following statements will change the value of i to 15?

a) k = 15;

b) *k = 15;

c) p = 15;

d) *p = 15;

e) Two or more of the answers will change i to 15.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Option D is the only correct answer.

For statement k=i
K will assigned with new addressed
It don't have any relation with i
So a and b are wrong
And for statement p=15
P points to address 15
So C is also wrong..

For *p=15 updates the content of I address
Example let 1000 is the address of I and 1002 is the address of k.
Now p holds 1000

*p =15 updates the content of address of 1000.

So Option D is correct answer..

Add a comment
Know the answer?
Add Answer to:
The following statements are in C++: 1. Consider the following statements: int *p; int i, k;...
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