🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: C Pointers: all 10 questions

Quiz: C Pointers · Question 9 of 10

With const int p = &x;, what is allowed?

With const int *p = &x;, what is allowed?

  1. A.*p = 5; (changing x through p)
  2. B.p = &y; (pointing p at another int)
  3. C.Neither
  4. D.Both
Answer & explanation

Correct answer: p = &y; (pointing p at another int)

const before the * protects the value pointed to, not the pointer; int *const p is the opposite.

Can you get the rest right without peeking?

Take the timed Quiz: C Pointers quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →