What will be the output of the following C program? int main()
What will be the output of the following C program?
#include <stdio.h>
int main()
{
int i = 1;
do
{
printf("%d ", i);
i++;
} while (i <= 5);
return 0;
}
Show answerHide answer
Correct answer: (C) 1 2 3 4 5
Explanation
The do-while prints i and then increments it while i <= 5, so it prints 1 2 3 4 5 and stops when i becomes 6.