Saved Bookmarks
| 1. |
What is the output of following statement? for(i=1; i<4; i++) printf(“%d”,(i%2) ? i : 2*i);(A) 1 4 3(B) 1 2 3(C) 2 4 6(D) 2 2 6 |
|
Answer» Correct option - (A) 1 4 3 Explanation:- for i=1, (i%2) is true so the statement will print 1; for for i=2, (i%2) is false so the statement will print 2*i=2*2=4; for for i=3, (i%2) is again true so the statement will print 3; for i=4, the statement is out from the loop. |
|