Comments on Loopy C Puzzle

Post Comment

Ryan said:

int i;
for (i = 0; abs(i) < 6; i--)
    printf(".");
01 Oct 2011 04:26 GMT (#1 of 6 comments)

Ryan said:

int i;
for (i = 0; -i < 6; i--)
    printf(".");
01 Oct 2011 04:46 GMT (#2 of 6 comments)

Sean said:

Changing the loop condition to i ^= 6; is another solution.

01 Oct 2011 04:48 GMT (#3 of 6 comments)

Ryan said:

Ah-ha, a tricky one:

int i;
for (i = 0; i ^= 6; i--)
    printf(".");
01 Oct 2011 04:54 GMT (#4 of 6 comments)

Ryan said:

Ah, Sean beat me to it. :(

01 Oct 2011 04:54 GMT (#5 of 6 comments)

Martin DeMello said:

for (i = 0; i + 6; i--)

will stop when i + 6 = 0.

01 Oct 2011 05:11 GMT (#6 of 6 comments)
Post Comment