ବ୍ୟବହାରକାରୀ:Snip1/List of Hello world program examples
The Hello world program is a simple computer program that prints (or displays) the string "Hello, world!" or some variant thereof. It is typically one of the simplest programs possible in almost all computer languages, and often used as first program to demonstrate a programming language. As such it can be used to quickly compare syntax differences between various programming languages. The following is a list of canonical hello world programs in 108 programming languages. ଛାଞ୍ଚ:Toc
A
[ସମ୍ପାଦନା]ABAP
[ସମ୍ପାଦନା]REPORT ZHELLOWORLD.
WRITE 'Hello, world!'.
ActionScript 3.0
[ସମ୍ପାଦନା]trace ("Hello, world!");
or (if you want it to show on the stage)
package com.example
{
import flash.text.TextField;
import flash.display.Sprite;
public class Greeter extends Sprite
{
public function Greeter()
{
var txtHello:TextField = new TextField();
txtHello.text = "Hello, world!";
addChild(txtHello);
}
}
}
Ada
[ସମ୍ପାଦନା]with Ada.Text_IO;
procedure Hello_World is
use Ada.Text_IO;
begin
Put_Line("Hello, world!");
end;
Adventure Game Studio Script
[ସମ୍ପାଦନା]Display("Hello, world!");
or (if you want to draw it to the background surface)
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawString(0, 100, Game.NormalFont, "Hello, world!");
surface.Release();
ALGOL
[ସମ୍ପାଦନା]BEGIN DISPLAY ("Hello, world!"); END.
ALGOL 68
[ସମ୍ପାଦନା]print("Hello, world!")
Amiga E
[ସମ୍ପାଦନା]PROC main() WriteF('Hello, world!') ENDPROC
APL
[ସମ୍ପାଦନା]⎕←'Hello, world!'
AppleScript
[ସମ୍ପାଦନା]display dialog "Hello, world!"
or if you want a button to trigger the dialog:
on helloWorld()
display dialog "Hello, world!"
end helloWorld
helloWorld()
Assembly Language — MOS Technology 6502, CBM KERNEL
[ସମ୍ପାଦନା]
A_CR = $0D ;carriage return
BSOUT = $FFD2 ;kernel ROM sub, write to current output device
;
LDX #$00 ;starting index in .X register
;
LOOP LDA MSG,X ;read message text
BEQ LOOPEND ;end of text
;
JSR BSOUT ;output char
INX
BNE LOOP ;repeat
;
LOOPEND RTS ;return from subroutine
;
MSG .BYT 'Hello, world!',A_CR,$00
Assembly language – x86 DOS
[ସମ୍ପାଦନା]; The output file is 22 bytes.
; 14 bytes are taken by "Hello, world!$
;
; Written by Stewart Moss - May 2006
; This is a .COM file so the CS and DS are in the same segment
;
; I assembled and linked using TASM
;
; tasm /m3 /zn /q hello.asm
; tlink /t hello.obj
.model tiny
.code
org 100h
main proc
mov ah,9 ; Display String Service
mov dx,offset hello_message ; Offset of message (Segment DS is the right segment in .COM files)
int 21h ; call DOS int 21h service to display message at ptr ds:dx
retn ; returns to address 0000 off the stack
; which points to bytes which make int 20h (exit program)
hello_message db 'Hello, world!$'
main endp
end main
Assembly language – x86 Windows 32-bit
[ସମ୍ପାଦନା]; This program displays "Hello, World!" in a windows messagebox and then quits.
;
; Written by Stewart Moss - May 2006
;
; Assemble using TASM 5.0 and TLINK32
;
; The output EXE is standard 4096 bytes long.
; It is possible to produce really small windows PE exe files, but that
; is outside of the scope of this demo.
.486p
.model flat,STDCALL
include win32.inc
extrn MessageBoxA:PROC
extrn ExitProcess:PROC
.data
HelloWorld db "Hello, world!",0
msgTitle db "Hello world program",0
.code
Start:
push MB_ICONQUESTION + MB_APPLMODAL + MB_OK
push offset msgTitle
push offset HelloWorld
push 0
call MessageBoxA
push 0
call ExitProcess
ends
end Start
Assembly language – x86-64 Linux, AT&T syntax
[ସମ୍ପାଦନା] .section .rodata
string:
.ascii "Hello, world!\n"
length:
.quad . -string #Dot = 'here'
.section .text
.globl _start #Make entry point visible to linker
_start:
movq $4, %rax #4=write
movq $1, %rbx #1=stdout
movq $string, %rcx
movq length, %rdx
int $0x80 #Call Operating System
movq %rax, %rbx #Make program return syscall exit status
movq $1, %rax #1=exit
int $0x80 #Call System Again
Assembly language – Z80
[ସମ୍ପାଦନା] CR EQU $0D ; carriage return
PROUT EQU $xxxx ; character output routine
;
LD HL,MSG ; Point to message
;
PRLOOP LD A,(HL) ; read byte from message
AND A ; set zero flag from byte read
RET Z ; end of text if zero
CALL PROUT ; output char
INC HL ; point to next char
JR PRLOOP ; repeat
;
MSG DB "Hello, world!",CR,0
;
AutoHotkey
[ସମ୍ପାଦନା]Msgbox, Hello, world!
Traytip,, Hello, world!
AutoIt
[ସମ୍ପାଦନା]Msgbox(64, "", "Hello, world!")
AWK
[ସମ୍ପାଦନା]BEGIN { print "Hello, world!" }
B
[ସମ୍ପାଦନା]BASIC
[ସମ୍ପାଦନା]PRINT "Hello, world!"
Batch File
[ସମ୍ପାଦନା]@echo Hello, world!
BCPL
[ସମ୍ପାଦନା]GET "LIBHDR" LET START() BE $( WRITES("Hello, world!*N") $)
BennuGD
[ସମ୍ପାଦନା]
import "mod_say"
Process Main()
Begin
say("Hello World!");
End
brainfuck
[ସମ୍ପାଦନା]+++++ +++++ initialize counter (cell #0) to 10
[ use loop to set the next four cells to 70/100/30/10/40
> +++++ ++ add 7 to cell #1
> +++++ +++++ add 10 to cell #2
> +++ add 3 to cell #3
> + add 1 to cell #4
> ++++ add 4 to cell #5
<<<<< - decrement counter (cell #0)
]
> ++ . print 'H'
> + . print 'e'
+++++ ++ . print 'l'
. print 'l'
+++ . print 'o'
>>> ++++ . print ','
<< ++ . print ' '
< +++++ +++ . print 'w'
----- --- . print 'o'
+++ . print 'r'
----- - . print 'l'
----- --- . print 'd'
> + . print '!'
> . print '\n'
C
[ସମ୍ପାଦନା]C
[ସମ୍ପାଦନା]#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello, world!\n");
return EXIT_SUCCESS;
}
C++
[ସମ୍ପାଦନା]#include <iostream>
int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}
C++/CLI
[ସମ୍ପାଦନା]using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
return 0;
}
C++/CX
[ସମ୍ପାଦନା]#include "stdafx.h"
#using <Platform.winmd>
using namespace Platform;
[MTAThread]
int main(Array<String^>^ args)
{
String^ message("Hello World!");
Details::Console::WriteLine(message);
}
C#
[ସମ୍ପାଦନା]using System;
class Program
{
public static void Main()
{
Console.WriteLine("Hello, world!");
}
}
Casio BASIC
[ସମ୍ପାଦନା]"HELLO, WORLD!"
CoffeeScript
[ସମ୍ପାଦନା]To display an alert dialog box:
alert 'Hello, world!'
To write to a console/debugging log:
console.log 'Hello, world!'
COMAL-80
[ସମ୍ପାଦନା]10 PRINT "Hello, world!"
Common Intermediate Language
[ସମ୍ପାଦନା].assembly Hello {}
.assembly extern mscorlib {}
.method static void Main()
{
.entrypoint
.maxstack 1
ldstr "Hello, world!"
call void [mscorlib]System.Console::WriteLine(string)
call string[mscorlib]System.Console::ReadKey(true)
pop
ret
}
ColdFusion Markup Language (CFML)
[ସମ୍ପାଦନା]CF Script:
<cfscript>
variables.greeting = "Hello, world!";
WriteOutput( variables.greeting );
</cfscript>
CFML Tags:
<cfset variables.greeting = "Hello, world!">
<cfoutput>#variables.greeting#</cfoutput>
Clojure
[ସମ୍ପାଦନା]Console version:
(println "Hello, world!")
GUI version:
(javax.swing.JOptionPane/showMessageDialog nil "Hello, world!")
COBOL
[ସମ୍ପାଦନା] IDENTIFICATION DIVISION.
PROGRAM-ID. HELLO-WORLD.
PROCEDURE DIVISION.
DISPLAY 'Hello, world!'.
STOP RUN.
D
[ସମ୍ପାଦନା]D
[ସମ୍ପାଦନା]import std.stdio;
void main()
{
writeln("Hello, world!");
}
Dart
[ସମ୍ପାଦନା]main()
{
print('Hello, world!');
}
DCL
[ସମ୍ପାଦନା]WRITE SYS$OUTPUT "Hello, world!"
Delphi
[ସମ୍ପାଦନା]{$APPTYPE CONSOLE}
begin
Writeln('Hello, world!');
end.
E
[ସମ୍ପାଦନା]Erlang
[ସମ୍ପାଦନା]io:format("~s~n", ["Hello, world!"])
F
[ସମ୍ପାଦନା]F#
[ସମ୍ପାଦନା]printfn "Hello, world!"
Falcon
[ସମ୍ପାଦନା] printl( "Hello, world!" )
or
> "Hello, world!"
Forth
[ସମ୍ପାଦନା]." Hello, world! "
Fortran
[ସମ୍ପାଦନା]Fortran 90 and later:
program hello
write(*,*) 'Hello, world!'
end program hello
OR
program hello
print *, 'Hello, world!'
end program hello
FORTRAN 77 and prior; also accepted in Fortran 90 and later:
PROGRAM HELLO
WRITE(*,*) 'Hello, world!'
END
OR
PROGRAM HELLO
PRINT *, 'Hello, world!'
END
Frost
[ସମ୍ପାଦନା]import "io.frost";
main:args {
[print string:"Hello, world!\n" format:{}];
}
G
[ସମ୍ପାଦନା]Game Maker Language
[ସମ୍ପାଦନା]show_message("Hello, World!");
Go
[ସମ୍ପାଦନା]package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
Groovy
[ସମ୍ପାଦନା]println "Hello, world!"
H
[ସମ୍ପାଦନା]Haskell
[ସମ୍ପାଦନା]main = putStrLn "Hello, world!"
Haxe
[ସମ୍ପାଦନା]class Main {
static function main() {
trace("Hello, world!");
}
}
HOP
[ସମ୍ପାଦନା](define-service (hello-world)
(<HTML>
(<HEAD>
(<TITLE> "Hello, world!"))
(<BODY>
"Hello, world!")))
HTML
[ସମ୍ପାଦନା]<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Hi!</title>
</head>
<body>
<p>Hello, world!</p>
</body>
</html>
I
[ସମ୍ପାଦନା]IDL
[ସମ୍ପାଦନା]print, "Hello, world!"
end
INTERCAL
[ସମ୍ପାଦନା]DO ,1 <- #13
PLEASE DO ,1 SUB #1 <- #238
DO ,1 SUB #2 <- #108
DO ,1 SUB #3 <- #112
DO ,1 SUB #4 <- #0
DO ,1 SUB #5 <- #64
DO ,1 SUB #6 <- #194
DO ,1 SUB #7 <- #48
PLEASE DO ,1 SUB #8 <- #22
DO ,1 SUB #9 <- #248
DO ,1 SUB #10 <- #168
DO ,1 SUB #11 <- #24
DO ,1 SUB #12 <- #16
DO ,1 SUB #13 <- #162
PLEASE READ OUT ,1
PLEASE GIVE UP
Io
[ସମ୍ପାଦନା] "Hello, world!" println
ISLISP
[ସମ୍ପାଦନା](format (standard-output) "Hello, world!")
J
[ସମ୍ପାଦନା]J
[ସମ୍ପାଦନା]'Hello, world!'
Java
[ସମ୍ପାଦନା]In console:
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, world!");
}
}
or in window with Swing:
import javax.swing.JFrame; //Importing class JFrame
import javax.swing.JLabel; //Importing class JLabel
public class HelloWorld {
public static void main(String[] args) {
JFrame frame = new JFrame(); //Creating frame
frame.setTitle("Hi!"); //Setting title frame
frame.add(new JLabel("Hello, world!"));//Adding text to frame
frame.pack(); //Setting size to smallest
frame.setLocationRelativeTo(null); //Centering frame
frame.setVisible(true); //Showing frame
}
}
or in dialog:
import javax.swing.JOptionPane;
public class HelloWorld {
public static void main(String[] args) {
javax.swing.JOptionPane.showMessageDialog(null, "Hello, world!");
}
}
JavaScript
[ସମ୍ପାଦନା]To write to a console/debugging log:
console.log('Hello, world!');
To display an alert dialog box:
alert('Hello, world!');
To write to an HTML document:
document.write('Hello, world!');
Using Mozilla's Rhino:
print('Hello, world!');
L
[ସମ୍ପାଦନା]Linden Scripting Language
[ସମ୍ପାଦନା]llSay(0,"Hello, world!");
llShout(0, "Hello, world!");
llSayRegion(0, "Hello, world!");
Lisp
[ସମ୍ପାଦନା](princ "Hello, world!")
Logo
[ସମ୍ପାଦନା]print [Hello, world!]
LOLCODE
[ସମ୍ପାଦନା]HAI
CAN HAS STDIO?
VISIBLE "HAI WORLD!"
KTHXBYE
Lua
[ସମ୍ପାଦନା]print "Hello, world!"
M
[ସମ୍ପାଦନା]M4
[ସମ୍ପାଦନା]Hello, world!
Malbolge
[ସମ୍ପାଦନା]('&%:9]!~}|z2Vxwv-,POqponl$Hjig%eB@@>}=<M:9wv6WsU2T|nm-,jcL(I&%$#" `CB]V?Tx<uVtT`Rpo3NlF.Jh++FdbCBA@?]!~|4XzyTT43Qsqq(Lnmkj"Fhg${z@>
Mathematica
[ସମ୍ପାଦନା]Print["Hello, world!"]
Maple
[ସମ୍ପାଦନା]print(`Hello, world!`);
MATLAB
[ସମ୍ପାଦନା]disp('Hello, world!')
mIRC Script
[ସମ୍ପାଦନା]echo -a Hello, world!
MUMPS
[ସମ୍ପାଦନା]main()
write "Hello, world!"
quit
O
[ସମ୍ପାଦନା]Oberon
[ସମ୍ପାଦନା]MODULE Hello; IMPORT Out; BEGIN Out.String("Hello, world!"); Out.Ln END Hello.
Obix
[ସମ୍ପାଦନା]system.console.write_line ( "Hello, world!" )
Objective-C
[ସମ୍ପାଦନା]#import <stdio.h>
int main(void)
{
printf("Hello, world!\n");
return 0;
}
Otherwise (by gcc on pre-OpenStep/Apple Object based runtime):
#import <stdio.h>
#import <objc/Object.h>
@interface Hello: Object
- (void) say;
@end
@implementation Hello
- (void) say {
printf("Hello, world!\n");
}
@end
int main() {
Hello *hello = [Hello new];
[hello say];
[hello free];
return 0;
}
Pre-Modern (post-1994 OpenStep based Foundation APIs:
@interface Hello:NSObject
- (void) say;
@end
@implementation Hello
- (void) say {
NSLog(@"Hello, world!");
}
@end
int main(int argc, char *argv[])
{
NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
Hello *hello = [Hello new];
[hello say];
[hello release];
[p release];
return 0;
}
Modern (llvm, ARC memory management):
@interface Hello:NSObject
- (void) say;
@end
@implementation Hello
- (void) say {
NSLog(@"Hello, world!");
}
@end
int main(int argc, char *argv[])
{
@autoreleasepool {;
[[Hello new] say];
}
return 0;
}
OCaml
[ସମ୍ପାଦନା] print_endline "Hello, world!"
Opa
[ସମ୍ପାଦନା]A "hello world" web server:
Server.start(Server.http,
{ title: "Hello, world!",
page: function() { <>Hello, world!</> } })
Oriel
[ସମ୍ପାଦନା]MessageBox(OK, 1, INFORMATION, "Hello, world!", "Oriel Says Hello", ResponseValue)
Oz
[ସମ୍ପାଦନା]{Show 'Hello World'}
P
[ସମ୍ପାଦନା]Pascal
[ସମ୍ପାଦନା]begin
WriteLn('Hello, world!');
end.
Pawn
[ସମ୍ପାଦନା]main()
{
print("Hello, world!");
}
Perl 5
[ସମ୍ପାଦନା]print "Hello, world!";
Or
use v5.10;
say 'Hello, world!';
PHP
[ସମ୍ପାଦନା]<?php echo 'Hello, world!' ?>
or
<?php print 'Hello, world!' ?>
or
<?= 'Hello, world!' ?>
PL/SQL
[ସମ୍ପାଦନା]SET SERVEROUTPUT ON;
BEGIN
DBMS_OUTPUT.PUT_LINE('Hello, world!');
END;
PostScript
[ସମ୍ପାଦନା]%!PS /Courier 72 selectfont 20 20 moveto (Hello World!) show showpage
PowerShell
[ସମ୍ପାଦନା]"Hello, world!"
Processing
[ସମ୍ପାଦନା]void setup(){
println("Hello, world!");
}
Prolog
[ସମ୍ପାଦନା]main :- write('Hello, world!'), nl.
Python 2
[ସମ୍ପାଦନା]print "Hello, world!"
Python 3
[ସମ୍ପାଦନା]print("Hello, world!")
R
[ସମ୍ପାଦନା]R
[ସମ୍ପାଦନା]cat('Hello, world!\n')
Racket
[ସମ୍ପାଦନା]Trivial "hello world" program:
"Hello, world!"
Running this program produces "Hello, world!"
. More direct version:
#lang racket
(display "Hello, world!")
A "hello world" web server using Racket's web-server/insta
language:
#lang web-server/insta
(define (start request) (response/xexpr '(html (body "Hello, world"))))
REXX
[ସମ୍ପାଦନା]say Hello, world!
RPL
[ସମ୍ପାଦନା]<< "Hello, world!" MSGBOX >>
RTL/2
[ସମ୍ପାଦନା]TITLE Hello, world!; LET NL=10; EXT PROC(REF ARRAY BYTE) TWRT; ENT PROC INT RRJOB(); TWRT("Hello, world!#NL#"); RETURN(1); ENDPROC;
Ruby
[ସମ୍ପାଦନା]puts "Hello, world!"
Rust
[ସମ୍ପାଦନା]fn main() { println("Hello, world!"); }
S
[ସମ୍ପାଦନା]Scala
[ସମ୍ପାଦନା]object HelloWorld extends App {
println("Hello, world!")
}
Scheme
[ସମ୍ପାଦନା](display "Hello, world!")
Shell
[ସମ୍ପାଦନା]echo Hello, world!
SimpleC
[ସମ୍ପାଦନା]OUT<"Hello, world!"
Simula
[ସମ୍ପାଦନା]Begin OutText ("Hello, world!"); Outimage; End;
Small Basic
[ସମ୍ପାଦନା]TextWindow.WriteLine("Hello, World!")
Smalltalk
[ସମ୍ପାଦନା]Transcript show: 'Hello, world!'.
SmileBASIC
[ସମ୍ପାଦନା]?"Hello, world!
or
PRINT "Hello, world!"
SNOBOL
[ସମ୍ପାଦନା]OUTPUT = 'Hello, world!' END
Speakeasy
[ସମ୍ପାଦନା]As an interactive statement :
"Hello, world!"
As a program :
program hello "Hello, world!" end
SQL
[ସମ୍ପାଦନା]SELECT 'Hello, world!' FROM DUMMY; -- DUMMY is a standard table in SAP HANA.
SELECT 'Hello, world!' FROM DUAL; -- DUAL is a standard table in Oracle.
SELECT 'Hello, world!' -- This will work in SQL Server.
Stata
[ସମ୍ପାଦନା]display "Hello, world!"
Supernova
[ସମ୍ପାଦନା]I want window and the window title is hello world.
T
[ସମ୍ପାଦନା]Tcl
[ସମ୍ପାଦନା]puts "Hello, world!"
TI-BASIC
[ସମ୍ପାଦନା]Disp "HELLO, WORLD!"
or
Output(1,1,"HELLO, WORLD!")
Turing
[ସମ୍ପାଦନା]put "Hello World!"
U
[ସମ୍ପାଦନା]UnrealScript
[ସମ୍ପାଦନା]Log("Hello, world!");
V
[ସମ୍ପାଦନା]Vala
[ସମ୍ପାଦନା]void main ()
{
print ("Hello, world!\n");
}
VBScript
[ସମ୍ପାଦନା]MsgBox "Hello World"
Verilog
[ସମ୍ପାଦନା]module hello();
initial begin
$display("Hello, world!");
$finish;
end
endmodule
VHDL
[ସମ୍ପାଦନା]entity hello_world is
end;
architecture hello_world of hello_world is
begin
stimulus : PROCESS
begin
assert false report "Hello, world!"
severity note;
wait;
end PROCESS stimulus;
end hello_world;
Visual Basic
[ସମ୍ପାଦନା] MsgBox "Hello, world!"
Visual Basic .NET
[ସମ୍ପାଦନା]Module Module1
Sub Main()
Console.WriteLine("Hello, world!")
End Sub
End Module
'non-console example:
Class Form1
Public Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load()
MsgBox("Hello, world!")
End Sub
End Class
X
[ସମ୍ପାଦନା]XSLT
[ସମ୍ପାଦନା]Main article : XSLT
<?xml version='1.0' encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0' > <xsl:output method="text"/> <xsl:template match="/"> <xsl:text>Hello World </xsl:text> </xsl:template> </xsl:stylesheet>
W
[ସମ୍ପାଦନା]Whitespace
[ସମ୍ପାଦନା]This example shows the program with syntax highlighting. Without highlighting, it would appear to be blank space.
S S S T S S T S S S L T L S S S S S T T S S T S T L T L S S S S S T T S T T S S L T L S S S S S T T S T T S S L T L S S S S S T T S T T T T L T L S S S S S T S T T S S L T L S S S S S T S S S S S L T L S S S S S T T T S T T T L T L S S S S S T T S T T T T L T L S S S S S T T T S S T S L T L S S S S S T T S T T S S L T L S S S S S T T S S T S S L T L S S S S S T S S S S T L T L S S L L L
External links
[ସମ୍ପାଦନା]- Nodewave's computer language comparison, examples implementing the same loop algorithm I will not throw paper airplanes in class.
- Rosetta Code hello world listing, hello world examples for 230 programming languages.
- List of Hello World Programs in 300 Programming Languages - C and C++ Programming Resources, hello world examples for 300 programming languages.
- Pages with syntax highlighting errors
- Computer programming
- Articles with example C code
- Articles with example C++ code
- Articles with example D code
- Articles with example Fortran code
- Articles with example Haskell code
- Articles with example Java code
- Articles with example JavaScript code
- Articles with example Pascal code
- Articles with example Perl code
- Articles with example Python code
- Articles with example Ruby code
- Articles with example C Sharp code
- Articles with example Racket code