001 # puzzle on c
By dholey
@dholey (1383)
India
January 20, 2007 12:50pm CST
/* WHAT WILL BE THE OUTPUT */
void main()
{
int i=1,j=1;
for( ; j ; printf(" %d %d",i,j) )
j=i++
2 responses
@tmaheshwari (170)
• India
22 Jan 07
good tricky program...
it will actually print 213141516170
and the reason is very simple, here the condition of quit is 'j' ... when 'j' becomes 'zero', for loop will quit.
Now, the processing part is
j = i++
@swaroop_sv2003 (531)
• India
21 Jan 07
Dholey i took some time to figure this out. I might be wrong. Was a bit difficult one. Since i is the only incremented in this problem only value of i would be changes and j would always be 1. While entering the loop for the first time, third argument which is the printf("%d%d",i,j) is never executed so there wont be 11. So the final answer would be
213141516171. Am i wrong?
@tmaheshwari (170)
• India
22 Jan 07
just a little... last digit is wrong.. may be it is just a typo mistake.. :)