
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tlug] C puzzle
Tod McQuillin writes:
>
> This C program:
>
> main() {
> int i, n=20;
> for(i = 0 ; i < n ; i--)
> printf("-");
> }
>
> Can be modified into a correct program for printing 20 '-' characters in a
> row by replacing a single character of the code.
>
> In fact, there are three different ways to do it.
main() {
int i, n=20;
for(i = 0 ;-i < n ; i--)
printf("-");
}
main() {
int i, n=20;
for(i = 0 ; i < n ; n--)
printf("-");
}
Ok, what's the third?
Marcus
--
/--------------------------------------------------------------------\
| Dr. Marcus O.C. Metzler | |
|--------------------------------|-----------------------------------|
| mocm@example.com | http://www.metzlerbros.de/ |
\--------------------------------------------------------------------/
Home |
Main Index |
Thread Index