#include<stdio.h> int main() { int n; for (n = 9; n!=0; n--) printf("n = %d", n--); return 0; } |
chevron_right
filter_none
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 7 5 3 1 -1 -3 -5 -7 -9 …
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
Recommended Posts:
- C | Loops & Control Structure | Question 1
- 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 6
- C | Loops & Control Structure | Question 7
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 11
- C | Loops & Control Structure | Question 12
- C | Loops & Control Structure | Question 13
- C | Loops & Control Structure | Question 14
- C | Loops & Control Structure | Question 15
- C | Loops & Control Structure | Question 16
- C | Loops & Control Structure | Question 17
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 20
- C | Loops & Control Structure | Question 21

