001 # puzzle on c

@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
• 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++
@dholey (1383)
• India
22 Jan 07
perfectly perfect so it became the best response .....
@dholey (1383)
• India
31 Jan 07
you are always welcom .... (where are you now a days .. i am missing you on mylot!!!!)
• India
23 Jan 07
thanks dholey... thanks for that :)
• 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?
• India
22 Jan 07
just a little... last digit is wrong.. may be it is just a typo mistake.. :)
@dholey (1383)
• India
22 Jan 07
nop, the code is correct and it will get executed and will give proper output ....check it again...