User Output - text
From Rosetta Code
Programming Task
This is a programming task. It lays out a problem which Rosetta Code users are encouraged to solve, using languages they know.
See also: User Output - graphical
[edit] Ada
Works with: GCC version 4.1.2
with Ada.Text_IO; use Ada.Text_IO; procedure Main is begin Put_Line ("Goodbye, World!"); end Main;
[edit] ALGOL 68
main: ( printf($"Goodbye, World!"l$) )
[edit] AppleScript
To show in Script Editor Result pane:
"Goodbye, World!"
To show in Script Editor Event Log pane: log "Goodbye, World!"
[edit] BASIC
Works with: BASICA
10 print "Goodbye World!"
Works with: QuickBasic version 4.5
PRINT "Goodbye, World!"
[edit] Befunge
0"!dlrow ,eybdooG">:v
^,_@
[edit] C
Works with: gcc version 4.0.1
#include <stdio.h> int main(int argc, char **argv) { printf("Goodbye, World!\n"); return 0; }
Or:
int main(int argc, char **argv){ puts("Goodbye, World!"); return 0; }
[edit] C#
Works with: Mono version 1.2
Works with: Visual C# version 2003
System.Console.WriteLine("Goodbye, World!");
[edit] C++
Works with: GCC version 4.1.2
Works with: Visual C++ version 2005
#include <iostream> using std::cout; using std::endl; int main () { cout << "Goodbye, World!" << endl; return 0; }
[edit] Clean
Start = "Goodbye, World!"
[edit] Common Lisp
(print "Goodbye, World!")
[edit] E
println("Goodbye, World!")
stdout.println("Goodbye, World!")
[edit] eC
class GoodByeApp : Application
{
void Main()
{
PrintLn("Goodbye, World!");
}
}
[edit] Erlang
io:format("Goodbye, world~n").
[edit] Forth
." Goodbye, World!"
Or as a whole program:
: goodbye ( -- ) ." Goodbye, World!" CR ;
[edit] Fortran
Works with: F77
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".
[edit] Haskell
main = putStrLn "Goodbye, world"
[edit] IDL
print,'Goodbye World'
[edit] Java
System.out.println("Goodbye, World!");
[edit] JavaScript
Works with: Firefox version 2.0
<script language="JavaScript"> document.write("Goodbye, World!"); </script>
Works with: NJS version 0.2.5
print('Hello, World!');
[edit] Lisaac
Works with: Lisaac version 0.13.1
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";);
[edit] Logo
Print includes a line feed:
print [Goodbye, world!]
Type does not:
type [Goodbye, world!]
[edit] LSE64
" Goodbye, World!" ,t nl
[edit] Lua
Works with: Lua version 5.1.1
print("Goodbye, World!")
or:
print "Goodbye, World!"
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.
[edit] Mathematica
Print["Goodbye, World!"]
[edit] MAXScript
print "Goodbye, World!"
or:
format "%" "Goodbye, World!"
[edit] mIRC Scripting Language
Works with: mIRC
alias saygoodbye { echo -a Goodbye! }
[edit] newLISP
Works with: newLisp version 9.0
(println "Goodbye, World!")
[edit] Objective-C
Works with: GCC
To print to stdout:
printf("Goodbye, World!");
To log a time-stamped message to the Console:
NSLog(@"Goodbye, World!");
[edit] OCaml
print_endline "Goodbye, World!"
[edit] Pascal
Works with: Free Pascal
program byeworld; begin writeln('Goodbye, World!'); end.
[edit] Perl
Works with: Perl version 5.8.8
print "Goodbye, World!\n";
Works with: Perl version 5.10.x
say 'Goodbye, World!';
[edit] PHP
echo "Goodbye, World!\n";
[edit] Pop11
printf('Goodbye, World!\n');
[edit] 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)".
[edit] PowerShell
Write-Host "Goodbye, World!"
# For extra flair, you can specify colored output Write-Host "Goodbye, World!" -foregroundcolor red
[edit] Python
Works with: Python version 2.4
print "Goodbye, World!"
The same using sys.stdout
import sys sys.stdout.write("Goodbye, World!\n")
In Python 3.0, print is being changed from a statement to a function.
Works with: Python version 3.0
print("Goodbye, World!")
[edit] Raven
'Goodbye, World!' print
[edit] Ruby
Works with: Ruby version 1.8.4
puts "Goodbye, World!"
or
$stdout.puts "Goodbye, World!"
[edit] Seed7
$ include "seed7_05.s7i";
const proc: main is func
begin
writeln("Goodbye, World!");
end func;
[edit] Scheme
Works with: Gauche
(display "Goodbye, world!") (newline)
or
(print "Goodbye, world!")
[edit] Smalltalk
Transcript show: 'Goodbye, world!'; cr.
Works with: GNU Smalltalk
'Goodbye, world!' printNl.
[edit] SNUSP
@\G.@\o.o.@\d.--b.@\y.@\e.>@\comma.@\.<-@\W.+@\o.+++r.------l.@\d.>+.! # | | \@------|# | \@@+@@++|+++#- \\ - | \@@@@=+++++# | \===--------!\===!\-----|-------#-------/ \@@+@@@+++++# \!#+++++++++++++++++++++++#!/
[edit] Tcl
Output to terminal:
puts "Goodbye, World"
Output to file:
puts $fileID "Goodbye, World"
[edit] UNIX Shell
Works with: Bourne Again SHell
#!/bin/bash echo "Goodbye World!"
[edit] Unlambda
`r``````````````.G.o.o.d.b.y.e.,. .W.o.r.l.di
[edit] V
"Goodbye! world" puts
[edit] Vedit macro language
Message("Goodbye, World!")
[edit] XSLT
<xsl:text>Goodbye, World! </xsl:text>
Categories: Programming Tasks | Basic language learning | Ada | ALGOL 68 | AppleScript | BASIC | Befunge | C | C sharp | C++ | Clean | Common Lisp | E | EC | Erlang | Forth | Fortran | Haskell | 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

