What is the output of following code:
void main()
{
int i;
for(i=0;i<5;++i)
{
printf("%d",i);
}
}
a. 0,1,2,3,4 b. 1,2,3,4,5
c. 1,2,3,4 d. error
void main()
{
int i;
for(i=0;i<5;++i)
{
printf("%d",i);
}
}
a. 0,1,2,3,4 b. 1,2,3,4,5
c. 1,2,3,4 d. error
b.1,2,3,4,5
ReplyDeleteoutput:
During execution,when i=0,in for loop ++i i.e. ++0=1.
hence,first output value is 1.
when i=4,4<5 is satisfied,++i=++4=5
so last output is 5.
Raj Kachare
ReplyDeleteAnswer is b)1,2,3,4,5
ya right ankit ans b
ReplyDelete