Algorithms Quiz | SP2 Contest 1 | Question 1
Predict the output of below C program:
a = 5, b = 10%9, i;
(i=1; i<10; i++)
(a != b);
"a = %d b = %d\n"
, a, b);
(A) 5 1
(B) Prints “a = 5 b = 1” ten times.
(C) a = 5 b = 1
(D) The program will not produce any output
Explanation: The printf statement is outside the if block because of the semicolon operator after the if statement and thus it is also outside the for loop block. So, it is executed only once.
Quiz of this Question