C | Loops & Control Structure | Question 12
#include <stdio.h> int main() { int i; for (i = 1; i != 10; i += 2) printf(" GeeksQuiz "); return 0; } |
chevron_right
filter_none
(A) GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
(B) GeeksQuiz GeeksQuiz GeeksQuiz …. infinite times
(C) GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
(D) GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz GeeksQuiz
Answer: (B)
Explanation: The loop termination condition never becomes true and the loop prints GeeksQuiz infinite times. In general, if a for or while statement uses a loop counter, then it is safer to use a relational operator (such as <) to terminate the loop than using an inequality operator (operator !=).
Recommended Posts:
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 2
- C | Loops & Control Structure | Question 8
- C | Loops & Control Structure | Question 1
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 13
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 14
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 15
- C | Loops & Control Structure | Question 16
- C | Loops & Control Structure | Question 17
- C | Loops & Control Structure | Question 21
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 20



