Multiple choice

What is the output of the following program? void main() { int m=10; int *p=&m; (*p)++; cout<<(*p)++; }

  1. 12

  2. 11

  3. 10

  4. Address of m

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The pointer p points to m (value 10). (*p)++ increments m to 11. Then cout<<(*p)++ prints 11 (post-increment returns the value before incrementing). Final value of m is 12, but output is 11.