Open In App
Related Articles

ISRO | ISRO CS 2015 | Question 74

Improve Article
Improve
Save Article
Save
Like Article
Like

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

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 06 Apr, 2018
Like Article
Save Article
Previous
Next
Similar Reads