Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

ISRO | ISRO CS 2015 | Question 74

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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

My Personal Notes arrow_drop_up
Last Updated : 06 Apr, 2018
Like Article
Save Article
Similar Reads