Strange behavior of simple For loop in C language

64 views Asked by At

I was just curious to do it and find the result, but I got really shocked...

Actually,

when we do this:

for(i=0; 0; i++)
 printf("hello");

it prints hello... which it should not.

and if do like this:

int a=0;
for(i=0;a;i++)
 printf("hello");

it doesn't print hello...

although the expected behavior is shown in if-else or while loop.. Can anyone explain?

0

There are 0 answers