What is the output of C Program?
void main({
int a=32;
do{
printf("%d", a);
a++
ifla >35)
break;
while(1);
Answers
void main()
{
int a=32;
do{
printf("%d", a);
a++
if(a >35)
break;
while(1);
__________________________
The output of this program.
__________________________
The output of this program is -
32 33 34
__________________________
In this program , do while loop us used. While(1) is an infinite loop which means that loop will run till there is no break condition or statement.
And there is a condition in this loop -
It means that if the value of a will become greater than 35 , loops bill be terminated.
In this program , given -
Because it is a do while loops , it will be executed at least 1 time whether condition is true or false.
Loops will run and 32 will be printed.
And the value of a will be incremented by 1. The value of a will become 33. It checks that (33> 35 )
the condition is false so the loop will be continued.
33 will be printed and the value of a will become 34.
It will check again (34 > 35) the condition is false again and loop will be continued.
The value of a will become 35 , it will check again (35>35) now condition is true because 35 is not greater than 35 and loop will be terminated.
So the output will be -
32 33 34
__________________________