October 6, 2023
October 6, 2023
October 6, 2023
###### UGC NET CS 2014 Dec – paper-3
October 6, 2023
 Question 29
The for loop
for (i=0; i<10; ++i)
printf(“%d”, i&1);
prints:
 A 0101010101 B 0111111111 C 0000000000 D 1111111111
Question 29 Explanation:
The loop will execute for 10 times, from “i” value 0 to 9
“&” is bitwise AND operator.

For a given i=0 , the value is 0&1 is 0000 & 0001 which is 0
i=1, 0001 & 0001 which is 1
i=2 , 0010 & 0001 which is 0
i=3 0011 & 0001 which is 1
i=4 , 0100 & 0001 which is 0
i=5 0101 & 0001 which is 1
i=6 , 1100 & 0001 which is 0
i=7 0111 & 0001 which is 1
i=8 , 1000 & 0001 which is 0
i=9 1001 & 0001 which is 1
So the output is 0101010101(from i=0 to 9)

Question 29 Explanation:
The loop will execute for 10 times, from “i” value 0 to 9
“&” is bitwise AND operator.

For a given i=0 , the value is 0&1 is 0000 & 0001 which is 0
i=1, 0001 & 0001 which is 1
i=2 , 0010 & 0001 which is 0
i=3 0011 & 0001 which is 1
i=4 , 0100 & 0001 which is 0
i=5 0101 & 0001 which is 1
i=6 , 1100 & 0001 which is 0
i=7 0111 & 0001 which is 1
i=8 , 1000 & 0001 which is 0
i=9 1001 & 0001 which is 1
So the output is 0101010101(from i=0 to 9)