I got this puzzle from a friend today: you have to change

There are 3 solutions AFAIK. The first two are silly, but the third one took me a while.

Enjoy! :)

**only one char**, either by**replacing**or**inserting**it, to fix the following code to print 42 asterisks:

int i, n=42;

main() {

for(i=0; i<n; i--) {

? ?printf("*");

}

}

There are 3 solutions AFAIK. The first two are silly, but the third one took me a while.

Enjoy! :)

inserting = into i<n won't work because the updater is i--.

Interesting puzzle....

replace the updater with n-- (not 100% sure though)

Interesting puzzle....

replace the updater with n-- (not 100% sure though)

n=-42

n--

abs(i) :P

n--

abs(i) :P

n--

i+n

-i < n

Thanks for this little puzzle QvasiModo ;)

i+n

-i < n

Thanks for this little puzzle QvasiModo ;)

Got n-- and -i < n, but didn't get i+n.... wow, that

n=-42 won't work because the first iteration of the for will have i=0, n=-42, i<n is 0 < -42 is false, so it won't print anything.

(no offense intended SpooK)

*is*C! because in C, 0 is the false value, so when i hits -42, i+n is -42+42 is 0, which is falsen=-42 won't work because the first iteration of the for will have i=0, n=-42, i<n is 0 < -42 is false, so it won't print anything.

(no offense intended SpooK)

n=sqrt(42)

In reality it doesn't matter, the answer is always "42" ;)

#define SIX 1+5

#define NINE 8+1

n=SIX * NINE;

But.... what's the question????? LOL

#define NINE 8+1

n=SIX * NINE;

But.... what's the question????? LOL

You are only allowed to add or insert 1 character, so here are my three (took me about 1 minute for the first 2, and about 4 more for the last one):

Mirno

i-- => n--

i < n => -i < n

i < n => i + n

Mirno

n--

i+n

-i < n

Thanks for this little puzzle QvasiModo ;)

You are only allowed to add or insert 1 character, so here are my three (took me about 1 minute for the first 2, and about 4 more for the last one):

i-- => n--

i < n => -i < n

i < n => i + n

Mirno

That's the answer exactly. And it took us about the same time too. :)

Fun, isn't it? Looks much simpler until you actually try to solve it... ;)