C Programming · Question 18 · Easy
What will be the output of the following C program?
#include <stdio.h>
int main(void) {
int i = 10;
do {
i -= 3;
} while (i > 0);
printf("%d", i);
return 0;
}
- -2
- -1
- 0
- 1
Answer and explanation
Answer: A. -2
Explanation: i goes 10 -> 7 -> 4 -> 1 -> -2. The loop stops when the condition i > 0 fails at -2, which is then printed.
Previous: What will be the output of the following C program? · Next: What will be the output of the following C program?
Practise c programming
Try a fresh set of c programming questions with an explanation after every answer, free and without signing up: C Programming practice. Or sit a full placement mock test.
More c programming questions
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
- What will be the output of the following C program?
More technical & programming practice
Java · Python · Data Structures · Algorithms · Object-Oriented Programming · DBMS · SQL · Operating Systems
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge