Tomer Gabel's annoying spot on the 'net RSS 2.0
# Friday, September 8, 2006

A friend sent me this riddle (which I imagine isn't his, but nevermind) via mail, and I thought it cute enough to share:

Find three ways to change/insert/delete a single character in the following code, so that the resulting code will print 20 star characters (*). Remember, for each solution you can only change one character, and there are at least three different solutions.

#include <stdio.h>

int main()
{
    int i, N = 20;
    for ( i = 0 ; i < N ; i-- )
        printf( "*" );
    return 0;
}

I'll post the solution in a few days, feel free to yell "eureka" in the comment section or whatever.

Friday, September 8, 2006 6:26:24 PM (Jerusalem Standard Time, UTC+02:00)  #    -
Development
Tracked by:
"Solution: A cute riddle in C" (Useless Inc.) [Trackback]
Me!
Send mail to the author(s) Be afraid.
Archive
<September 2024>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345
All Content © 2024, Tomer Gabel
Based on the Business theme for dasBlog created by Christoph De Baene (delarou)