Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C | Loops & Control Structure | Question 8

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article




#include<stdio.h>
int main()
{
   int n;
   for (n = 9; n!=0; n--)
     printf("n = %d", n--);
   return 0;
}

What is the output?
(A) 9 7 5 3 1
(B) 9 8 7 6 5 4 3 2 1
(C) Infinite Loop
(D) 9 7 5 3


Answer: (C)

Explanation: The program goes in an infinite loop because n is never zero when loop condition (n != 0) is checked. n changes like 9 7 5 3 1 -1 -3 -5 -7 -9 …

Quiz of this Question

My Personal Notes arrow_drop_up
Last Updated : 01 Jun, 2021
Like Article
Save Article
Similar Reads