I am not sure if this kind of questions are appropriate here, but... By changing (or adding) one character make this program print '*' exactly 20 times
void main(){
int i, n=20;
for (i=0; i<n; i--)
printf("*");
}
Any ideas?
CodePudding user response:
It seems you mean the following change from
for (i=0; i<n; i--)
^^^
to
for (i=0; i<n; n--)
^^^
Here is one character i
is substituted for one character n
.
Another way (if it is allowed by the puzzle) is to add one character '-'
like
for (i=0; -i<n; i--)
^^^
Note: By the way pay attention to that according to the C Standard the function main without parameters shall be declared like :)
int main( void )
CodePudding user response:
either do i or (i-- & n-=2or any other positive number greater the 1)