Multiple choice

The output of the following code snippet is __________ ( ) main( ) { int b[]= { 10,20,30,40,50 }; int i; for(i=0; i<=4 ;i++) Printf(n %d,*(b+i)); }

  1. 1 2 3 4 5

  2. 2000 2002 2004 2006 2008

  3. 10 20 30 40 50

  4. error in code

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

The expression *(b+i) is pointer arithmetic equivalent to b[i]. As i iterates from 0 to 4, this accesses each element of array b sequentially. The array contains 10, 20, 30, 40, 50, which are printed in order.