the printf function returns 1 when it prints a string..
for (1;1&&i--;1)
{
printf("bat");
}
note that i=2 has been cunningly initialized before. and the decrement of i
has been done in middle expression of the for loop
hence, actually its like
for(;i--;)
{
}

how many times will this execute? Twice.i=1 and i=2, for i=O, the middle
condition shall become O and hence fails.


therefore the ouput.

On Sun, Jan 9, 2011 at 6:48 PM, siva viknesh <sivavikne...@gmail.com> wrote:

>
> #include<stdio.h>
> int main()
> {
> int i=2;
> for(printf("cat ");printf("rat ")&&i--;printf("mat "))
> {
>
>            printf("bat ");
>
>  }
>
> }
>
>
> ouput : cat rat bat mat rat bat mat rat
>
> can anybody plz explain how we get this output??
> --
> Regards,
> $iva
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algoge...@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to