Output question confusion


#1

Output of the following ‘C’ fragment is
For(i=1, j=10; i<6; ++i,–j)
Printf(“%d%d”,i,j);

a) 1 10 2 9 3 8 4 7 5 6
b) 1 2 3 4 5 10 9 8 7 6
c) 1 1 1 1 1 9 9 9 9 9
d) None of these


#2

answer would be
1 102 93 84 75 6


#3

by the given condition ‘i’ value undergo increment and goes on while ‘j’ value undergo decrement .
for every iteration ‘i’ value should be less than 6 (thats the condition given).
so the answer must be first option ie “a”-1 10 2 9 3 8 4 7 5 6.


#4

In each iteration, i value increments by 1 and j value decrements by 1. As the loop executes until i<6, it is executed 5 times. Hence the answer is
1 10 2 9 3 8 4 7 5 6. So the answer is option a