I saw this post in one of the blogs. Try solving
Here is a small C/C++ code snippet,
int n = 20;
for(i = 0; i < n; i--)
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
LoL...
anyways, if you find how many ever answers in five mins you are good.
if you take more than five mins, you are either jobless or trying out for a shift.
#define - +
:P
only one ascii char ramak, only one
:(
for( int i = 0; -i < n; i--)
i < -n
n = -20
i am brilliant , i am brilliant !!!
oops, internally afraid that i did something like that #define again :(
correct
//i < -n//
//n = -20//
0 is greater than -20. so, no loop
:P
for( int i = 0; i < n; n--)
click here
:)
Sen,
ok, let me give the blog url which i was referring to
http://haroonsaeed.wordpress.com/2008/01/14/try-your-coding-skills/