Multiple choice

What will be 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. Unknown value

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

p points to z[0]=5. *p+1 dereferences p (getting 5) then adds 1, giving 6. The precedence is: (*p) + 1, not *(p+1). The latter would give z[1]=6, but that's not what's written.