Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | Loops & Control Structure | Question 12

  • Difficulty Level : Basic
  • Last Updated : 09 Feb, 2013


Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.



#include <stdio.h>   
int main() 
  int i;   
  for (i = 1; i != 10; i += 2) 
    printf(" GeeksQuiz "); 
  return 0; 
}

(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 !=).

My Personal Notes arrow_drop_up
Recommended Articles
Page :