C Puzzle!
Pages: [1]
|
|
Programming Help
|
superjer
superjer

2005 Mar 20 • 3742
|
This code is intended to print 20 minus signs, but it does not work:
#include <stdio.h>
main()
{
int i = 0, n = 20;
do
{
printf("-");
i--;
} while ( i < n );
}
There are at least 4 ways to fix it by changing exactly one character. Find!
|
|
|
|
|
(Edited 2009 Jul 5 at 13:14)
2009 Jul 1 at 16:30
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2009 Jul 1 at 17:09
|
|
|
superjer
superjer

2005 Mar 20 • 3742
|
*** You have found 1 of the 4 solutions. ***
This is just a puzzle, don't worry about compiler warnings, etc. You don't have to return an int to get it to compile, anyway.
|
|
|
|
|
2009 Jul 1 at 17:18
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2009 Jul 1 at 17:25
|
|
|
Killer-Duck
Homicidal Anatidae

2008 Mar 5 • 1169
633 ₧
|
...
} while ( -i < n );
Maybe?
QUACK! QUACK!
|
|
|
|
|
2009 Jul 2 at 13:18
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2009 Jul 3 at 14:15
|
|
|
superjer
superjer

2005 Mar 20 • 3742
|
*** You have found 2 of the 4 solutions. ***
Good job killer.
Yes, you can change a white-space character. But only ONE!
|
|
|
|
|
2009 Jul 3 at 17:29
|
|
|
the_cloud_system
polly pushy pants

2008 Aug 1 • 2787
-6 ₧
|
ok im just gona ask
what
how
txt doc?
i dont know
can you explane
moo moo moo, moo.
|
|
|
|
|
2009 Jul 3 at 18:13
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2009 Jul 5 at 04:00
|
|
|
superjer
superjer

2005 Mar 20 • 3742
|
Down Rodeo said: Uhm, changing the assignment n =-20; might work?
that will only print one minus sign because i is never less than n.
|
|
|
|
|
2009 Jul 5 at 12:50
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2009 Jul 6 at 09:44
|
|
|
thegreat
2009 Jul 9 • 1
|
WOW the most funny and newbie c puzzle ever...the increment shuld be
i++;
or make
.
.
.
int i=20,n=0;
do{
.
.
}while(i>n);
|
|
|
|
|
(Edited 2009 Jul 9 at 08:19)
2009 Jul 9 at 08:18
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2009 Jul 9 at 09:10
|
|
|
Mate de Vita
Kelli

2008 Oct 4 • 2397
159 ₧
|
I don't remember how exactly the while check works (is 0 true or false?), but would this work?
Anyway just bumping this truck.
...and that's the bottom line because Mate de Vita said so.
Who controls the past, controls the future. Who controls the present, controls the past.
|
|
|
|
|
(Edited 2010 Jan 16 at 07:49)
2010 Jan 16 at 07:48
|
|
|
Down Rodeo
Cap'n Moth of the Firehouse


2007 Oct 19 • 5258
57,583 ₧
|
|
|
|
|
|
2010 Jan 16 at 09:28
|
|
|
superjer
superjer

2005 Mar 20 • 3742
|
It took a while but you got it. GG Mate Davate.
|
|
|
|
|
2010 Jan 22 at 18:28
|
|
|
|
Pages: [1]
|