Hello world/Text
You are encouraged to solve this task according to the task description, using any language you may know.
In this User Output task, the goal is to display the string "Goodbye, World!" on a text console.
See also: User Output - graphical
Ada
<ada>with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin
Put_Line ("Goodbye, World!");
end Main;</ada>
ALGOL 68
main: ( printf($"Goodbye, World!"l$) )
AppleScript
To show in Script Editor Result pane: <applescript>"Goodbye, World!"</applescript>
To show in Script Editor Event Log pane: log "Goodbye, World!"
BASIC
10 print "Goodbye World!"
<qbasic>PRINT "Goodbye, World!"</qbasic>
Befunge
0"!dlrow ,eybdooG">:v ^,_@
C
<c>#include <stdio.h>
int main(int argc, char **argv) {
printf("Goodbye, World!\n");
return 0;
}</c> Or: <c>int main(int argc, char **argv){
puts("Goodbye, World!"); return 0;
}</c>
C#
<csharp>System.Console.WriteLine("Goodbye, World!");</csharp>
C++
<cpp>#include <iostream>
using std::cout; using std::endl;
int main () {
cout << "Goodbye, World!" << endl;
return 0;
}</cpp>
Clean
Start = "Goodbye, World!"
Common Lisp
(print "Goodbye, World!")
dc
[Goodbye, World!]p
E
println("Goodbye, World!")
stdout.println("Goodbye, World!")
eC
class GoodByeApp : Application { void Main() { PrintLn("Goodbye, World!"); } }
Erlang
io:format("Goodbye, world~n").
Forth
." Goodbye, World!"
Or as a whole program:
: goodbye ( -- ) ." Goodbye, World!" CR ;
Fortran
Simplest case - display using default formatting:
print *,"Goodbye, world"
Use explicit output format:
100 format (5X,A,"!") print 100,"Goodbye, world"
Output to channels other than stdout goes like this:
write (89,100) "Goodbye, world"
uses the format given at label 100 to output to unit 89. If output unit with this number exists yet (no "OPEN" statement or processor-specific external unit setting), a new file will be created and the output sent there. On most UNIX/Linux systems that file will be named "fort.89".
Haskell
main = putStrLn "Goodbye, world"
Icon
procedure main () write ( "Goodbye World" ) end
IDL
print,'Goodbye World'
Java
<java>System.out.println("Goodbye, World!");</java>
JavaScript
<javascript><script language="JavaScript"> document.write("Goodbye, World!"); </script></javascript>
<javascript>print('Hello, World!');</javascript>
Lisaac
You can print to standard output in Lisaac by calling STRING.print or INTEGER.print:
Section Header // The Header section is required. + name := GOODBYE; // Define the name of this object. Section Public - main <- ("Goodbye, World!\n".print;);
However, it may be more straightforward to use IO.print_string instead:
Section Header // The Header section is required. + name := GOODBYE2; // Define the name of this object. Section Public - main <- (IO.put_string "Goodbye, World!\n";);
Logo
Print includes a line feed:
print [Goodbye, world!]
Type does not:
type [Goodbye, world!]
LSE64
" Goodbye, World!" ,t nl
Lua
<lua>print("Goodbye, World!")</lua>
or:
<lua>print "Goodbye, World!"</lua>
In Lua, parentheses are optional for function calls when there is only one argument and this argument is either a string or a table constructor.
Mathematica
Print["Goodbye, World!"]
MAXScript
print "Goodbye, World!"
or:
format "%" "Goodbye, World!"
mIRC Scripting Language
alias saygoodbye { echo -a Goodbye! }
newLISP
(println "Goodbye, World!")
Objective-C
To print to stdout:
printf("Goodbye, World!");
To log a time-stamped message to the Console:
NSLog(@"Goodbye, World!");
OCaml
<ocaml>print_endline "Goodbye, World!"</ocaml>
Pascal
<pascal>program byeworld; begin
writeln('Goodbye, World!');
end.</pascal>
Perl
<perl>print "Goodbye, World!\n";</perl>
<perl>say 'Goodbye, World!';</perl>
PHP
<php>echo "Goodbye, World!\n";</php>
Pop11
printf('Goodbye, World!\n');
PostScript
The "==" and "=" operators display the topmost element of the stack with or without processing. Thus:
(Goodbye world) ==
will display the string "(Goodbye world)" while
(Goodbye world) =
will display the content of the the string "(Goodbye wolrd)".
PowerShell
Write-Host "Goodbye, World!"
# For extra flair, you can specify colored output Write-Host "Goodbye, World!" -foregroundcolor red
Python
<python>print "Goodbye, World!"</python>
The same using sys.stdout <python>import sys sys.stdout.write("Goodbye, World!\n")</python>
In Python 3.0, print is being changed from a statement to a function.
<python>print("Goodbye, World!")</python>
Raven
'Goodbye, World!' print
Ruby
puts "Goodbye, World!" or $stdout.puts "Goodbye, World!"
Seed7
$ include "seed7_05.s7i"; const proc: main is func begin writeln("Goodbye, World!"); end func;
Scheme
(display "Goodbye, world!") (newline)
or
(print "Goodbye, world!")
Smalltalk
Transcript show: 'Goodbye, world!'; cr.
'Goodbye, world!' printNl.
SNUSP
@\G.@\o.o.@\d.--b.@\y.@\e.>@\comma.@\.<-@\W.+@\o.+++r.------l.@\d.>+.! # | | \@------|# | \@@+@@++|+++#- \\ - | \@@@@=+++++# | \===--------!\===!\-----|-------#-------/ \@@+@@@+++++# \!#+++++++++++++++++++++++#!/
Tcl
Output to terminal:
puts "Goodbye, World"
Output to file:
puts $fileID "Goodbye, World"
UNIX Shell
#!/bin/bash echo "Goodbye World!"
Unlambda
`r``````````````.G.o.o.d.b.y.e.,. .W.o.r.l.di
V
"Goodbye! world" puts
Vedit macro language
Message("Goodbye, World!")
XSLT
<xsl:text>Goodbye, World! </xsl:text>
- Programming Tasks
- Basic language learning
- Ada
- ALGOL 68
- AppleScript
- BASIC
- Befunge
- C
- C sharp
- C++
- Clean
- Common Lisp
- Dc
- E
- EC
- Erlang
- Forth
- Fortran
- Haskell
- Icon
- IDL
- Java
- JavaScript
- Lisaac
- Logo
- LSE64
- Lua
- Mathematica
- MAXScript
- MIRC Scripting Language
- NewLISP
- Objective-C
- OCaml
- Pascal
- Perl
- PHP
- Pop11
- PostScript
- PowerShell
- Python
- Raven
- Ruby
- Seed7
- Scheme
- Smalltalk
- SNUSP
- Tcl
- UNIX Shell
- Unlambda
- V
- Vedit macro language
- XSLT