G
Guest
Hello World!
In 'comp.lang.c' said:Hello World!
Wrong. It's
#include <stdio.h>
int main ()
{
puts ("Hello World!");
return 0;
}
August said:.... snip ...
#include <stdio.h>
int main(void)
{
do { puts("Hello, world!"); } while(1);
return 0;
}
August Derleth said:Or, if you want to annoy someone:
#include <stdio.h>
int main(void)
{
do { puts("Hello, world!"); } while(1);
return 0;
}
(Interestingly, more than a few programming examples seem to think the
Hello, world! program /should/ be an infinite loop. I have no idea why.)
Old Wolf said:I think the "return 0;" is superfluous here (and may even generate
a compiler warning for unreachable code).
10 PRINT "HELLO"
20 GOTO 10
Hello, world! program /should/ be an infinite loop. I have no idea why.)
In said:Since the return never gets executed, is the program correct under
C90 if the line is elided?
Chuck, making trouble.
Old said:I think the "return 0;" is superfluous here (and may even generate
a compiler warning for unreachable code).
10 PRINT "HELLO"
20 GOTO 10
Old said:I think the "return 0;" is superfluous here (and may even generate
a compiler warning for unreachable code).
10 PRINT "HELLO"
20 GOTO 10
program Nikolaus;
var
there_is_a_cold_day_in_hell : integer;
begin
there_is_a_cold_day_in_hell := 0;
repeat
writeln('Wotsit Wirth');
until there_is_a_cold_day_in_hell;
end.
<g,d&rf>
Joona I Palaste said:[...]var
there_is_a_cold_day_in_hell : integer; [...]
until there_is_a_cold_day_in_hell;
Unlike C, Pascal has an explicit boolean type, and does not implicitly
convert integers into booleans. Therefore the above code won't even
compile.
10 PRINT "GOODBYE"
20 GOSUB 10
It's been a long time..
Irrwahn said:<snip>
program Nikolaus;
var
there_is_a_cold_day_in_hell : integer;
begin
there_is_a_cold_day_in_hell := 0;
repeat
writeln('Wotsit Wirth');
until there_is_a_cold_day_in_hell;
end.
<g,d&rf>
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.