ISRO | ISRO CS 2015 | Question 74
The for loop
for (i=0; i<10; ++i) printf("%d", i&1);
prints:
(A) 0101010101
(B) 0111111111
(C) 0000000000
(D) 1111111111
Answer: (A)
Explanation: & operator is used in C to perform bitwise AND operation.
for (i=0; i<10; ++i) printf("%d", i&1);
i=0: 0000 AND 0001 = 0000 i=1: 0001 AND 0001 = 0001 i=2: 0010 AND 0001 = 0000 i=3: 0011 AND 0001 = 0001 . . and so on till i=9.
Output printed will be = 0101010101
Option (A) is correct.
Quiz of this Question
Please Login to comment...