What is the output of the following code? int main() {
What is the output of the following code?
#include <stdio.h>
int main() {
int i = 5;
do {
printf("%d ", i);
i--;
} while (i > 5);
return 0;
}
Show answerHide answer
Correct answer: (D) 5
Explanation
A do-while body runs at least once, so 5 is printed. Then i becomes 4 and the condition 4 > 5 is false, so the loop ends.