m3ph1st0s's programming puzzle 3 (C): “Easy bug”
3.1

for( i = 0;-i &lt; n; i-- )
for( i = 0; i &lt; n; n-- )
for( i = 0; i + n; i-- )


Any of these changes will make the program output 20 '+' signs. This one is close:

for( i = 0;~i &lt; n; i-- )


It outputs 21 '+' signs.

3.2.1

I found at least 112 ways to solve this problem inserting one letter. Not all of them may work on all compilers.

int n = 20L;
int n = 20f;
int n = 20d;
uint n = 20;

for( i = 0L; ... )
for( i = 0f; ... )
for( i = 0d; ... )

iprintf("+");
printf("+x");
printf("x+");


For the last two, substitute any letter for x to give you 104 possible solutions. Using either of the last two lines will change the output, but the output will still be the same for all 3 corrected programs.

3.2.2

All I've come up with are some things that get cast back to the number 20 on assignment to int.

int n = 20L;
int n = 20.001;
int n = 20.999;
int n = 20 + 0x100000000L;