Multiple choice

What is the output of the following program? void main() { int z[]={5,6,7,8,9,10}; int *p; p=z; cout<<*p+1; }

  1. Base address of z

  2. 5

  3. 6

  4. None of the above

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

The pointer p points to z[0](value 5). The expression *p+1 dereferences p first (getting 5), then adds 1, resulting in 6. Dereference has higher precedence than addition.