C | Loops & Control Structure | Question 1
#include <stdio.h> int main() { int i = 1024; for (; i; i >>= 1) printf("GeeksQuiz"); return 0; } |
chevron_right
filter_none
How many times will GeeksQuiz be printed in the above program?
(A) 10
(B) 11
(C) Infinite
(D) The program will show compile-time error
Answer: (B)
Explanation: In for loop, mentioning expression is optional. >>= is a composite operator. It shifts the binary representation of the value by 1 to the right and assigns the resulting value to the same variable. The for loop is executed until value of variable i doesn’t drop to 0.
Recommended Posts:
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 2
- C | Loops & Control Structure | Question 3
- C | Loops & Control Structure | Question 4
- C | Loops & Control Structure | Question 5
- C | Loops & Control Structure | Question 16
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 17
- C | Loops & Control Structure | Question 6
- C | Loops & Control Structure | Question 7
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 20
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 21
- C | Loops & Control Structure | Question 8



