Question

1. For the declarations below, which expression is TRUE if ptr1 and ptr2 point at the...

1. For the declarations below, which expression is TRUE if ptr1 and ptr2 point at the same object?
int *ptr1;
int *ptr2;

a. ptr1 == ptr2

b. None of the above is true

c. ptr1 != ptr2

d. &ptr1 == &ptr2

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

a. ptr1 == ptr2 is true. ptr1 and ptr2 represent the address of the object. They both represent the same object. so, It gives TRUE.

Option c.ptr1!=ptr2 gives FALSE.

Because they both point to the same object and they are equal so it gives FALSE.

Option d. &ptr1 == &ptr2 is not correct. Because ptr1 and ptr2 are pointers. So *ptr is value and ptr is address. & is used for normal variables. the pointer doesn't need &.

Add a comment
Know the answer?
Add Answer to:
1. For the declarations below, which expression is TRUE if ptr1 and ptr2 point at the...
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