Programa Olá Mundo: diferenças entre revisões

Conteúdo apagado Conteúdo adicionado
bot: revertidas edições de Predo Octavio ( modificação suspeita : -27), para a edição 56591869 de Salebot
Elilopes (discussão | contribs)
exemplos
Linha 1:
[[Imagem:PSP-Homebrew.jpeg|200px|thumb|Programa Olá Mundo sendo executado em um [[PlayStation Portable|PSP]], uma forma de ''[[homebrew]]''.]]
O '''"Olá Mundo"''' ou '''"Alô Mundo"''' é um famoso [[programa de computador]] de teste que imprime/exibe a frase "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 [[Fluxos padrão#Saída padrão (stdout)|dispositivo de saída]]. É utilizado como um teste ou como um exemplo de código minimalista de uma [[linguagem de programação]].<ref name="Coleção">{{Citar web |url=http://helloworldsite.he.funpic.de/hello.htm |título=The Hello World Collection |acessodata=6 de dezembro de 2011 |autor=Wolfram Rösler |data=25 de setembro de 2010 |publicado=helloworldsite.he.funpic.de |língua=inglês}}</ref> Um programa de propósito semelhante é o [[algoritmo de Trabb Pardo-Knuth]].<ref>{{Citar web |url=http://www.c2.com/cgi/wiki?TpkAlgorithm |título=Tpk Algorithm |língua=inglês |acessodata=6 de dezembro de 2011}}</ref><ref>{{Citar web |url=http://cs.fit.edu/~ryan/compare/ |título=TPK Algorithm in Different Programming Languages |acessodata=6 de dezembro de 2011 |autor=Ryan Stansifer |data=12 de julho de 2011 |publicado=cs.fit.edu |língua=inglês}}</ref>
 
O primeiro programa Olá Mundo de que se tem conhecimento foi implementado na [[B (linguagem de programação)|linguagem B]], para o livro ''A Tutorial Introduction to the Language B'':<ref name="B">{{Citar web |url = http://cm.bell-labs.com/cm/cs/who/dmr/btut.pdf|título = A Tutorial Introduction to the Language B|acessodata = 7 de dezembro de 2011|autor = Brian W. Kernighan|data = 1996|publicado = Lucent Technologies Inc.|língua = inglês|ligação inativa = sim}}</ref>
Linha 13:
b 'o, w';
c 'orld';
</syntaxhighlight>
 
== Exemplos ==
Exemplos de programação das 20 linguagens mais populares:<ref>{{Citar web|titulo=Olá Mundo em 9 linguagens de programação|url=https://terminalroot.com.br/2016/10/blog-linux-ola-mundo-9-linguagens.html|obra=Terminal Root - Linux e Desenvolvimento|acessodata=2020-01-29|primeiro=Marcos|ultimo=Oliveira}}</ref><ref>{{Citar web|titulo=‘Olá Mundo’ em 26 linguagens de codificação diferentes – BookMaps|url=http://bookmaps.co/go-on/ola-mundo-em-26-linguagens-de-codificacao-diferentes/|acessodata=2020-01-29|lingua=pt-BR}}</ref><ref>{{Citar web|titulo=Olá Mundo em 25 Linguagens de Programação: Proposta, Docs e Links.|url=https://terminalroot.com.br/2019/10/linguagem-de-programacao.html|obra=Terminal Root - Linux e Desenvolvimento|acessodata=2020-01-29|primeiro=Marcos|ultimo=Oliveira}}</ref>
 
Java<syntaxhighlight lang="java">
//Java visual com swing
import javax.swing.JFrame; // classe JFrame
import javax.swing.JLabel; // classe JLabel
public class HelloWorld
{
public static void main(String[] args)
{
JFrame frame = new JFrame(); //criando frame
frame.setTitle("Hi!"); //título do frame
frame.add(new JLabel("Hello, world!"));//adicionando texto ao frame
frame.pack(); //tamanho para smallest
frame.setLocationRelativeTo(null); //entralizando frame
frame.setVisible(true); //exibindo frame
}
}
</syntaxhighlight>C<syntaxhighlight lang="c">
#include <stdio.h>
int main()
{
printf("Olá, Mundo!\n");
return 0;
}
</syntaxhighlight>C++<syntaxhighlight lang="c++">
#include <iostream>
int main()
{
std::cout << "Olá, Mundo!\n";
return 0;
}
</syntaxhighlight>Python<syntaxhighlight lang="python">
print "Hello, world!"
</syntaxhighlight>C#<syntaxhighlight lang="c#">
using System;
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Olá mundo!");
}
}
</syntaxhighlight>JavaScript<syntaxhighlight lang="javascript">
document.write('Olá mundo!');
</syntaxhighlight>Visual Basic .NET<syntaxhighlight lang="vb.net">
Module Module1
Sub Main()
Console.WriteLine("Hello, world!")
End Sub
End Module
</syntaxhighlight>R<syntaxhighlight lang="r">
cat('Olá mundo!')
</syntaxhighlight>PHP<syntaxhighlight lang="php">
<?php echo "Olá, Mundo!"; ?>
</syntaxhighlight>MATLAB<syntaxhighlight lang="matlab">
disp('Olá mundo!')
</syntaxhighlight>Swift<syntaxhighlight lang="swift">
println("Olá mundo!")
</syntaxhighlight>Objective-C<syntaxhighlight lang="objective-c">
int main(void)
{
NSLog(@"Olá mundo!");
return 0;
}
</syntaxhighlight>Assembly<syntaxhighlight lang="objective-c">
section .text
global _start
 
_start:
 
mov edx,len
mov ecx,msg
mov ebx,1
mov eax,4
int 0x80
 
mov eax,1
int 0x80
 
section .data
 
msg db 'Olá mundo!',0xa
len equ $ - msg
</syntaxhighlight>Perl<syntaxhighlight lang="perl">
#!/usr/bin/env perl
print "Olá mundo!\n";
</syntaxhighlight>Ruby<syntaxhighlight lang="ruby">
puts "Olá mundo!"
</syntaxhighlight>Delphi<syntaxhighlight lang="delphi">
program OlaMundo;
begin
Writeln('Olá mundod!');
end.
</syntaxhighlight>Go<syntaxhighlight lang="go">
package main
import "fmt"
 
func main()
{
fmt.Printf("Olá mundo!\n")
}
</syntaxhighlight>SQL<syntaxhighlight lang="sql">
SELECT "Olá mundo!"
</syntaxhighlight>Visual Basic<syntaxhighlight lang="visualfoxpro">
Message.Info("Olá mundo!")
</syntaxhighlight>