Archive

Archive for January, 2008

Try your coding skills !

January 14, 2008 12 comments

Here is a small C/C++ code snippet,

int n = 20;

for( int i = 0; i < n ; i—) // i minus minus(in case of typo)

printf(“Hello World!”) ;

First try to find the answer to this program. It will obviously be an infinite loop or memory over flow or …

The question is to make this snippet work and print the “Hello World!” 20 times correctly as if the statement i— would have been i++.

The restriction however is to change only one ASCII character in this code. This means you can change, replace, move, introduce only one character to this program and the program still remains a valid C/C++ code.

There are three possible ways I know to do this. May be there are more. If you find two then you are good, if three you are brilliant and if more than extraordinary 😉

Have happy time solving this.

Advertisements