Programa Olá Mundo: diferenças entre revisões
Eu concertei alguns erros dos códigos (Java e Perl), um erro de escrita (estava escrito: "mundod") e deixei todos os olá mundos iguais ("Olá, mundo") |
bot: revertidas edições de 189.4.221.85 ( modificação suspeita : -453), para a edição 57658643 de ThrasherÜbermensch |
||
Linha 19: | Linha 19: | ||
Java<syntaxhighlight lang="java"> |
Java<syntaxhighlight lang="java"> |
||
//Java visual com swing import javax.swing.JFrame; // classe JFrame import javax.swing.JLabel; // classe JLabel public class HelloWorld |
|||
//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) |
public static void main(String args) |
||
{ |
{ |
||
JFrame frame = new JFrame(); |
JFrame frame = new JFrame(); //criando frame |
||
frame.setTitle(" |
frame.setTitle("Hi!"); //título do frame |
||
frame.add(new JLabel(" |
frame.add(new JLabel("Hello, world!"));//adicionando texto ao frame |
||
frame.pack(); |
frame.pack(); //tamanho para smallest |
||
frame.setLocationRelativeTo(null); |
frame.setLocationRelativeTo(null); //entralizando frame |
||
frame.setVisible(true); |
frame.setVisible(true); //exibindo frame |
||
} |
} |
||
} |
} |
||
Linha 40: | Linha 35: | ||
int main() |
int main() |
||
{ |
{ |
||
printf("Olá, Mundo!\n"); |
|||
return 0; |
|||
} |
} |
||
</syntaxhighlight>C++<syntaxhighlight lang="c++"> |
</syntaxhighlight>C++<syntaxhighlight lang="c++"> |
||
Linha 47: | Linha 42: | ||
int main() |
int main() |
||
{ |
{ |
||
std::cout << "Olá, Mundo!\n"; |
|||
return 0; |
|||
} |
} |
||
</syntaxhighlight>Python<syntaxhighlight lang="python"> |
</syntaxhighlight>Python<syntaxhighlight lang="python"> |
||
print(" |
print("Hello, world!") |
||
</syntaxhighlight>C#<syntaxhighlight lang="c#"> |
</syntaxhighlight>C#<syntaxhighlight lang="c#"> |
||
using System; |
using System; |
||
Linha 58: | Linha 53: | ||
public static void Main(string args) |
public static void Main(string args) |
||
{ |
{ |
||
Console.WriteLine("Olá |
Console.WriteLine("Olá mundo!"); |
||
} |
} |
||
} |
} |
||
</syntaxhighlight>JavaScript<syntaxhighlight lang="javascript |
</syntaxhighlight>JavaScript<syntaxhighlight lang="javascript"> |
||
document.write('Olá |
document.write('Olá mundo!'); |
||
</syntaxhighlight>Visual Basic .NET<syntaxhighlight lang="vb.net"> |
</syntaxhighlight>Visual Basic .NET<syntaxhighlight lang="vb.net"> |
||
Module Module1 |
Module Module1 |
||
Sub Main() |
Sub Main() |
||
Console.WriteLine(" |
Console.WriteLine("Hello, world!") |
||
End Sub |
End Sub |
||
End Module |
End Module |
||
</syntaxhighlight>R<syntaxhighlight lang="r"> |
</syntaxhighlight>R<syntaxhighlight lang="r"> |
||
cat('Olá |
cat('Olá mundo!') |
||
</syntaxhighlight>PHP<syntaxhighlight lang="php"> |
</syntaxhighlight>PHP<syntaxhighlight lang="php"> |
||
<?php echo "Olá, Mundo!"; ?> |
<?php echo "Olá, Mundo!"; ?> |
||
</syntaxhighlight>MATLAB<syntaxhighlight lang="matlab"> |
</syntaxhighlight>MATLAB<syntaxhighlight lang="matlab"> |
||
disp('Olá |
disp('Olá mundo!') |
||
</syntaxhighlight>Swift<syntaxhighlight lang="swift"> |
</syntaxhighlight>Swift<syntaxhighlight lang="swift"> |
||
println("Olá |
println("Olá mundo!") |
||
</syntaxhighlight>Objective-C<syntaxhighlight lang="objective-c"> |
</syntaxhighlight>Objective-C<syntaxhighlight lang="objective-c"> |
||
int main(void) |
int main(void) |
||
{ |
{ |
||
NSLog(@"Olá |
NSLog(@"Olá mundo!"); |
||
return 0; |
return 0; |
||
} |
} |
||
</syntaxhighlight>Assembly<syntaxhighlight lang=" |
</syntaxhighlight>Assembly<syntaxhighlight lang="objective-c"> |
||
section .text |
section .text global _start |
||
global _start |
|||
_start: |
_start: |
||
Linha 98: | Linha 92: | ||
int 0x80 |
int 0x80 |
||
section .data |
section .data |
||
msg db 'Olá |
msg db 'Olá mundo!',0xa len equ $ - msg |
||
len equ $ - msg |
|||
</syntaxhighlight>Perl<syntaxhighlight lang="perl"> |
</syntaxhighlight>Perl<syntaxhighlight lang="perl"> |
||
#!/usr/bin/env perl |
#!/usr/bin/env perl print "Olá mundo!\n"; |
||
print "Olá mundo!\n"; |
|||
</syntaxhighlight>Ruby<syntaxhighlight lang="ruby"> |
</syntaxhighlight>Ruby<syntaxhighlight lang="ruby"> |
||
puts "Olá |
puts "Olá mundo!" |
||
</syntaxhighlight>Delphi<syntaxhighlight lang="delphi"> |
</syntaxhighlight>Delphi<syntaxhighlight lang="delphi"> |
||
program OlaMundo; |
program OlaMundo; |
||
begin |
begin |
||
Writeln('Olá |
Writeln('Olá mundod!'); |
||
end. |
end. |
||
</syntaxhighlight>Go<syntaxhighlight lang="go"> |
</syntaxhighlight>Go<syntaxhighlight lang="go"> |
||
Linha 117: | Linha 109: | ||
func main() |
func main() |
||
{ |
{ |
||
fmt.Printf("Olá |
fmt.Printf("Olá mundo!\n") |
||
} |
} |
||
</syntaxhighlight>SQL<syntaxhighlight lang="sql"> |
</syntaxhighlight>SQL<syntaxhighlight lang="sql"> |
||
SELECT "Olá |
SELECT "Olá mundo!" |
||
</syntaxhighlight>Visual Basic<syntaxhighlight lang="visualfoxpro"> |
</syntaxhighlight>Visual Basic<syntaxhighlight lang="visualfoxpro"> |
||
Message.Info("Olá |
Message.Info("Olá mundo!") |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
Revisão das 00h10min de 5 de março de 2020
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 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]
main( ) {
extrn a, b, c;
putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';
Exemplos
Exemplos de programação das 20 linguagens mais populares:[5][6][7]
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
}
}
C
#include <stdio.h>
int main()
{
printf("Olá, Mundo!\n");
return 0;
}
C++
#include <iostream>
int main()
{
std::cout << "Olá, Mundo!\n";
return 0;
}
Python
print("Hello, world!")
C#
using System;
class Program
{
public static void Main(string args)
{
Console.WriteLine("Olá mundo!");
}
}
JavaScript
document.write('Olá mundo!');
Visual Basic .NET
Module Module1
Sub Main()
Console.WriteLine("Hello, world!")
End Sub
End Module
R
cat('Olá mundo!')
PHP
<?php echo "Olá, Mundo!"; ?>
MATLAB
disp('Olá mundo!')
Swift
println("Olá mundo!")
Objective-C
int main(void)
{
NSLog(@"Olá mundo!");
return 0;
}
Assembly
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
Perl
#!/usr/bin/env perl print "Olá mundo!\n";
Ruby
puts "Olá mundo!"
Delphi
program OlaMundo;
begin
Writeln('Olá mundod!');
end.
Go
package main import "fmt"
func main()
{
fmt.Printf("Olá mundo!\n")
}
SQL
SELECT "Olá mundo!"
Visual Basic
Message.Info("Olá mundo!")
Ver também
Referências
- ↑ Wolfram Rösler (25 de setembro de 2010). «The Hello World Collection» (em inglês). helloworldsite.he.funpic.de. Consultado em 6 de dezembro de 2011
- ↑ «Tpk Algorithm» (em inglês). Consultado em 6 de dezembro de 2011
- ↑ Ryan Stansifer (12 de julho de 2011). «TPK Algorithm in Different Programming Languages» (em inglês). cs.fit.edu. Consultado em 6 de dezembro de 2011
- ↑ Brian W. Kernighan (1996). «A Tutorial Introduction to the Language B» (PDF) (em inglês). Lucent Technologies Inc. Consultado em 7 de dezembro de 2011 [ligação inativa]
- ↑ Oliveira, Marcos. «Olá Mundo em 9 linguagens de programação». Terminal Root - Linux e Desenvolvimento. Consultado em 29 de janeiro de 2020
- ↑ «'Olá Mundo' em 26 linguagens de codificação diferentes – BookMaps». Consultado em 29 de janeiro de 2020
- ↑ Oliveira, Marcos. «Olá Mundo em 25 Linguagens de Programação: Proposta, Docs e Links.». Terminal Root - Linux e Desenvolvimento. Consultado em 29 de janeiro de 2020