Programa Olá Mundo

Origem: Wikipédia, a enciclopédia livre.
(Redirecionado de Olá Mundo)
Ir para: navegação, pesquisa
Programa Olá Mundo sendo executado em um PSP, uma forma de homebrew.

O "Olá Mundo" ou "Alô Mundo" é um famoso programa de computador que imprime "Olá, Mundo!" (ou "Hello, World!"), usualmente seguido de uma quebra de linha, com algumas variações como inexistência do ponto de exclamação e letras em minúscula, no dispositivo de saída. É utilizado como um teste ou como um exemplo de código minimalista de uma linguagem de programação.1 Um programa de propósito semelhante é o algoritmo de Trabb Pardo-Knuth.2 3

O primeiro programa Olá Mundo de que se tem conhecimento foi implementado na linguagem B, para o livro A Tutorial Introduction to the Language B.4

Índice

Linguagens de programação comuns [editar]

Exemplos de programas Olá Mundo em linguagens de programação comuns:1

ABAP [editar]

REPORT OlaMundo.
WRITE 'Olá, Mundo!'.

Ada [editar]

with Ada.Text_IO; 
 
procedure OlaMundo is
begin
  Ada.Text_IO.Put_Line("Olá, Mundo!");
  Ada.Text_IO.New_Line;
end OlaMundo;

ActionScript [editar]

trace ("Olá, Mundo!")

AppleScript [editar]

display dialog "Olá, Mundo"

Assembly [editar]

variable:
   .message   db   "Olá, Mundo!$"
code:
   mov  ah, 9
   mov  dx, offset .message
   int  0x21
   ret

Awk [editar]

BEGIN {
        print("Olá, Mundo!")
}

B [editar]

O primeiro programa Olá Mundo de que se tem conhecimento foi implementado na linguagem B, para o livro A Tutorial Introduction to the Language B.4

main( ) {
 extrn a, b, c;
 putchar(a); putchar(b); putchar(c); putchar('!*n');
}
 
a 'hell';
b 'o, w';
c 'orld';

Ou, equivalente:

main() {
   putchar('Olá, Mundo!*n');
}

Bash [editar]

echo "Olá, Mundo!"

BASIC [editar]

PRINT "Olá, Mundo!"

Boo [editar]

print("Olá, Mundo!")

C [editar]

K&R C [editar]

#include <stdio.h>
 
int main(void)
{
   puts("Olá, Mundo!");
   return 0;
}

C99 [editar]

int main()
{
   puts("Olá, Mundo!");
}

C++ [editar]

#include <iostream>
 
int main()
{
   std::cout << "Olá, Mundo!" << std::endl;
   return 0;
}

Ou, equivalente:

#include <iostream>
 
using namespace std;
 
int main()
{
   cout << "Olá, Mundo!" << endl;
   return 0;
}

C♯ [editar]

using System;
 
namespace Teste
{
    class OlaMundo
    {
        static void Main()
        {
            Console.WriteLine("Olá, Mundo!");
        }
    }
}

Clipper / dBase / xBase / Visual FoxPro [editar]

? "Olá, Mundo!"

Clojure [editar]

(println "Olá, Mundo!")

COBOL [editar]

IDENTIFICATION DIVISION.
PROGRAM-ID.     HELLO-WORLD.
 
ENVIRONMENT DIVISION.
 
DATA DIVISION.
 
PROCEDURE DIVISION.
DISPLAY "Olá, Mundo!".
STOP RUN.

Ou, equivalente:

DISPLAY "Olá, Mundo!".

D [editar]

import std.stdio;
 
void main()
{
   writefln("Olá, Mundo!");
}

Dart [editar]

main() {
  print('Olá, Mundo!');
}

Delphi [editar]

Program Ola_Mundo;
 
{$APPTYPE CONSOLE}
 
begin
   WriteLn('Olá, Mundo!');
end.

Ou, equivalente:

Program Ola_Mundo;
 
begin
   ShowMessage('Olá, Mundo!');
end.

Ou, equivalente:

Program Ola_Mundo;
 
begin
   MessageDlg('Olá, Mundo!', mtinformation, [mbok], 0);
end.

Erlang [editar]

-module(ola).
 
-export([ola/0]).
 
ola() ->
   io:format("Olá, Mundo!~n", []).

Euphoria [editar]

puts(1, "Olá, Mundo!\n")

F♯ [editar]

printfn "Olá, Mundo!"

Fantom [editar]

class OlaMundo
{
  static Void main()
  {
    echo("Olá, Mundo!")
  }
}

Forth [editar]

: OLA
  ."Olá, Mundo!" CR
;

Fortran [editar]

PROGRAM HELLO
WRITE(*,10)
10 FORMAT('Olá, Mundo!')
STOP
END

Game Maker Language [editar]

draw_text(x,y,"Olá, Mundo!");

Ou, equivalente:

show_message("Olá, Mundo!");

Go [editar]

package main
 
import "fmt"
 
func main() {
    fmt.Printf("Olá, Mundo!\n")
}

Groovy [editar]

println("Olá, Mundo!")

Haskell [editar]

olamundo :: IO()
olamundo = putStrLn "Olá, Mundo!"

Icon / Unicon [editar]

procedure main()
   write("Olá, Mundo!")
end

Java [editar]

public class OlaMundo {
    public static void main(String[] args) {
        System.out.println("Olá, Mundo!");
    }
}

JavaScript [editar]

document.write( 'Olá, mundo!' );

ou

alert( 'Olá, mundo!' );

ou

console.log( 'Olá, mundo!' );

Linden Scripting Language [editar]

default
{
  state_entry()
  {
    llSay(0, "Olá, Mundo!");
  }
}

Lisp [editar]

(print "Olá, Mundo!\n")

[editar]

print [Olá, Mundo!]

Lua [editar]

print "Olá, Mundo!"

Objective-C [editar]

#import <stdio.h>
 
int main(void)
{
   puts("Olá, Mundo!");
   return 0;
}

Pascal [editar]

program OlaMundo(output);
begin
  WriteLn('Olá, Mundo!');
end.

Ou, se estiver sendo usado o compilador Borland Pascal 7 para Windows:

PROGRAM OlaMundo;
 
USES
  WinCRT;
 
BEGIN
  InitWinCRT;
  WriteLn('Olá, Mundo!');
  ReadLn;
  DoneWinCRT;
END.

Perl [editar]

print "Olá, Mundo!";

PHP [editar]

<?php
   echo "Olá, Mundo!";
?>

Ou, equivalente:

<?php
    print "Olá, Mundo!";
?>

PL/SQL [editar]

SET ServerOutPut ON Size[sc_sql] }
 BEGIN
   SYS.DBMS_OUTPUT.PUT_LINE('Olá, Mundo!');
 END;

Portugol [editar]

algoritmo OlaMundo

inicio escreva("Olá, Mundo!") fim

Prolog [editar]

write('Olá, Mundo!').

Python [editar]

print("Olá, Mundo!")

Ruby [editar]

puts "Olá, Mundo!"

Scala [editar]

object OlaMundo {
  def main(args: Array[String]) {
    println("Olá, Mundo!")
  }
}

Ou, equivalente:

object OlaMundo extends Application {
  println("Olá, Mundo!")
}

Scheme [editar]

(display "Olá, Mundo!")
(newline)

Smalltalk [editar]

Transcript show: 'Olá, Mundo!'.

SQL [editar]

SELECT 'Olá, Mundo!';

Tcl [editar]

puts "Olá, Mundo!"

Visual Basic / Visual Basic .NET [editar]

Private Sub Form_Load()
    Print "Olá, Mundo!"
End Sub

Ou, equivalente em Visual Basic .NET (VB.NET):

Imports System.Console
 
Class OlaMundo
 
    Public Shared Sub Main()
        WriteLine("Olá, Mundo!")
    End Sub
 
End Class

Ver também [editar]

Referências

  1. a b Wolfram Rösler (25 de setembro de 2010). The Hello World Collection (em inglês). helloworldsite.he.funpic.de. Página visitada em 6 de dezembro de 2011.
  2. Tpk Algorithm (em inglês). Página visitada em 6 de dezembro de 2011.
  3. Ryan Stansifer (12 de julho de 2011). TPK Algorithm in Different Programming Languages (em inglês). cs.fit.edu. Página visitada em 6 de dezembro de 2011.
  4. a b Brian W. Kernighan (1996). A Tutorial Introduction to the Language B (em inglês). Lucent Technologies Inc.. Página visitada em 7 de dezembro de 2011.

Ligações externas [editar]