What will be the output of given program?
#include<stdio.h>
void main()
{
int a=3;
for(;a;printf("%d ", a--);
}
#include<stdio.h>
void main()
{
int a=3;
for(;a;printf("%d ", a--);
}
A. no output
B. 3 2 1 0
C. 3 2 1
D. infinity loop
Answer: Option C
Solution (By Examveda Team)
Decrement operator in for
loop statement are executed until the condition is true.
So it is executed till "a" not equal to zero and printf statement inside for
loop print a value of "a"
Join The Discussion