edited by
513 views

2 Answers

0 votes
0 votes
After entering into the loop the array value changes as

a[0]=2

a[1]=3

a[2]=4

a[3]=4

a[4]=5

a[5]=6

a[6]=7

a[7]=8

After entering the second for loop we will get

a[0=2

a[1]=3

a[2]=3

a[3]=2

a[4]=5

a[5]=6

a[6]=7

a[7]=8

answer will be i=2 a[i]=3
0 votes
0 votes

In first for loop
Loop 1  : i = 0, a[0] = 2, i = 1
Loop 2 : i = 2, a[2] = 4, i = 3
Loop 3 : i = 4 and since 4 > 3, we exit from loop

i -- ; // i value will be decremented i.e i = 3.

In second for loop, i is created locally, so  it won't have any effect on the i that is present outside the loop
Here a[3] decremented twice, at j = 7 and j = 6. So a[3] will be equal to 2 after this for loop

Printf() will print 3 and 2 as output, option c is correct here.

Related questions

2 votes
2 votes
0 answers
1
suhel khan asked Oct 10, 2017
394 views
How this question will be solved?