فهرست مثال‌های برنامه Hello World

یک **[[برنامه Hello World]]،** یک برنامهٔ رایانه‌ای ساده است که جمله «!Hello, world» را در صفحۀ نمایش چاپ می‌کند. معمولاً ساده‌ترین برنامهٔ ممکنی است که می‌توان در زبان‌های برنامه‌نویسی مختلف نوشت و یک عمل سنتی است که بسیاری از برنامه‌نویسان که قصد آموزش یک زبان برنامه‌نویسی را دارند، توصیه به نوشتن آن می‌کنند که اولین قدم در یادگیری آن زبان برنامه‌نویسی است. بیشتر از این برنامه برای مقایسه نحو دو زبان مختلف استفاده می‌شود. در زیر فهرستی از برنامه‌های Hello World مرسوم در ۹۱ زبان برنامه‌نویسی آمده‌است.

## آباپ


```actionscript
REPORT HELLOWORLD.
WRITE 'Hello, world!'.
```


## اکشن‌اسکریپت


```actionscript
trace ("Hello, world!");
```

یا:

```actionscript
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


```c
Display("Hello, world!");
```

یا:

```c
DrawingSurface *surface = Room.GetDrawingSurfaceForBackground();
surface.DrawString(0, 100, Game.NormalFont, "Hello, world!");
surface.Release();
```


## الگول


```
BEGIN
  DISPLAY ("Hello, world!");
END.
```


## ALGOL 68


```algol68
print("Hello, world!")
```


## Amiga E

```
PROC main()
  WriteF('Hello, world!')
ENDPROC
```


## ای‌پی‌ال

```apl
'Hello, world'
```


## Assembly Language — MOS Technology 6502, [[kernal|CBM KERNEL]]

```asm
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
```


## اسمبلی x86 داس


```asm
; 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
```


## زبان اسمبلی x86 ویندوز ۳۲ بیتی


```asm
; 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
```


## زبان اسمبلی - x86-64 لینوکس، ای‌تی‌اندتی


```asm
.section .rodata
string:
.ascii "Hello, world!\n\0"
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
```


## زبان اسمبلی - Z80

```asm
EQU CR    = #0D          ; carriage return
 EQU PROUT = #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
         JSR PROUT        ; output char
         INC HL           ; point to next char
         JR  PRLOOP       ; repeat
 ;
 MSG     DB  "Hello, world!",CR,00
 ;
```


## AutoHotkey


```autohotkey
Msgbox, Hello, world!
```


```autohotkey
Traytip,, Hello, world!
```


## AutoIt


```autoit
Msgbox(64, "", "Hello, world!")
```


## AWK


```awk
BEGIN { print "Hello, world!" }
```


## بیسیک


```qbasic
PRINT "Hello, world!"
```


## Batch File


```dos
@echo Hello, world!
```


## BCPL

```
GET "LIBHDR"

LET START() BE
$(WRITES("Hello, world!*N")
$)
```


## brainfuck


```bf
+++++ +++++             initialize counter (cell #0) to 10
[                       use loop to set the next four cells to 70/100/30/10
  > +++++ ++              add  7 to cell #1
  > +++++ +++++           add 10 to cell #2
  > +++                   add  3 to cell #3
  > +                     add  1 to cell #4
    <<<<-                  decrement counter (cell #0)
]
> ++.                  print 'H'
> +.                   print 'e'
+++++ ++.              print 'l'
.                       print 'l'
+++.                   print 'o'
> ++.                  print ' '
<<+++++ +++++ +++++.  print 'W'
>.                     print 'o'
+++.                   print 'r'
---- -.               print 'l'
---- ---.             print 'd'
> +.                   print '!'
>.                     print '\n'
```


## سی


```c
#include <stdio.h>
void main()
{
    printf("Hello World!");
}
```


## سی++


```cpp
#include <iostream>
using namespace std;
int main()
{
    cout << "Hello, world!" << endl;
    return 0;
}
```


## سی شارپ


```csharp
using System;
class Program
{
    public static void Main()
    {
        Console.WriteLine("Hello, world!");
        Console.ReadKey(true);
    }
}
```


## Casio BASIC


```qbasic
"HELLO, WORLD!"
```


## Common Intermediate Language


```cil
.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:

```cfm
<cfscript>
    variables.greeting = "Hello, world!";
    WriteOutput(variables.greeting);
</cfscript>
```


CFML Tags:

```cfm
<cfset variables.greeting = "Hello, world!">
<cfoutput>#variables.greeting#</cfoutput>
```


## کلوژر

نسخه ی پیشانه ای (کنسولی):


```clojure
(println "Hello, world!")
```


نسخه ی gui:


```clojure
(javax.swing.JOptionPane/showMessageDialog nil "Hello, world!")
```


## کوبول


```cobol
IDENTIFICATION DIVISION.
       PROGRAM-ID. HELLO-WORLD.
       PROCEDURE DIVISION.
           DISPLAY 'Hello, world!'.
           STOP RUN.
```


## دی


```d
import std.stdio;

void main()
{
  writeln("Hello, world!");
}
```


## دارت


```dart
main()
{
  print('Hello, world!');
}
```


## DCL

```dcl
WRITE SYS$OUTPUT "Hello, world!"
```


## دلفی


```delphi
{$APPTYPE CONSOLE}
begin
  Writeln('Hello, world!');
end.
```


## Erlang


```erlang
io:format("~s~n", ["Hello, world!"])
```


## F


```fsharp
printfn "Hello, world!"
```


## Falcon


```falcon
printl("Hello, world!")
```

or

```falcon
> "Hello, world!"
```


## Forth


```forth
." Hello, world! "
```


## فورترن

(Fortran 95 and later)

```fortran
program hello
    write (*,*) 'Hello, world!'
end program hello
```

(Fortran 90)

```fortran
program hello
   print *, 'Hello, world!'
end program hello
```

OR (FORTRAN 77 and prior)

```fortran
PROGRAM HELLO
       PRINT *, 'Hello, world!'
       END
```


## Game Maker Language


```gml
str='Hello, world!'

//Using the show_message() function:
show_message(str);

//Using the draw_text() function:
draw_text(0,0,str);
```


## Go


```go
package main

import "fmt"

func main() {
   fmt.Println("Hello, world!")
}
```


## Groovy


```groovy
println "Hello, world!"
```


## Haskell


```haskell
main = putStrLn "Hello, world!"
```


## HOP

```scheme
(define-service (hello-world)
  (<HTML>
     (<HEAD>
(<TITLE> "Hello, world!"))
     (<BODY>
"Hello, world!")))
```


## اچ‌تی‌ام‌ال


```html5
<!DOCTYPE html>
<html>
<body>
Hello, world!
</body>
</html>
```


## IDL


```idl
print, "Hello, world!"
end
```


## Io


```io
"Hello, world!" println
```


## ISLISP


```lisp
(format (standard-output) "Hello, world!")
```


## جی

  'Hello, world!'

## جاوا


```java
public class HelloWorld {
   public static void main(String[] args) {
       System.out.println("Hello, world!");
   }
}
```


## جاوااسکریپت

To write to an HTML document:

```javascript
document.write('Hello, world!');
```


To display an alert dialog box:

```javascript
alert('Hello, world!');
```


To write to a console/debugging log:

```javascript
console.log('Hello, world!');
```


Using Mozilla's Rhino:

```javascript
print('Hello, world!');
```


Using Windows Script Host:

```js
WScript.Echo("Hello, world!");
```


## Kotlin


```javascript
package hello

fun main(args: Array<String>) {
  println("Hello, world!")
}
```


## لیسپ


```lisp
(princ "Hello, world!")
```


## Logo


```lisp
print [Hello, world!]
```


## لوآ


```lua
print("Hello, World!")
```


## M4

```
Hello, world!
```


## Malbolge

```
(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc
```


## Mathematica


```mathematica
Print["Hello, world!"]
```


## Maple


```matlab
print(`Hello, world!`);
```


## متلب


```matlab
disp('Hello, world!')
```


## mIRC Script


```
echo -a Hello, world!
```


## MUMPS


```matlab
main()
 write "Hello, world!"
 quit
```


## Oberon

```oberon2
MODULE Hello;
  IMPORT Out;
BEGIN
  Out.String("Hello, world!");
  Out.Ln
END Hello.
```


## Obix

```
system.console.write_line ("Hello, world!")
```


## Objective-C


```objc
# import <stdio.h>

int main(void)
{
    printf("Hello, world!\n");
    return 0;
}
```


Otherwise (by gcc on pre-OpenStep/Apple Object based runtime):

```objc
# 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:

```objc
@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):


```objc
@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


```ocaml
print_endline "Hello, world!"
```


## Opa

A "hello world" سرور وب:

```opa
Server.start(Server.http,
    { title: "Hello, world!",
      page: function() { <>Hello, world!</> } })
```


## Oriel

```
MessageBox(OK, 1, INFORMATION, "Hello, world!", "Oriel Says Hello", ResponseValue)
```


## پاسکال


```pascal
program HelloWorld;
uses crt;

begin
  WriteLn('Hello, world!');
end.
```


## Pawn


```pawn
main()
{
    print("Hello, world.");
}
```


## Perl 5


```perl
print "Hello, world!";
```

Or

```perl
use v5.10;
say 'Hello, world!';
```


## پی‌اچ‌پی


```php
<?php echo 'Hello, world!' ?>
```


or


```php
<?php print 'Hello, world' ?>
```


or


```php
<?= 'Hello, world!' ?>
```


## PL/SQL


```plsql
SET SERVEROUTPUT ON;
BEGIN
    DBMS_OUTPUT.PUT_LINE('Hello, world!');
END;
```


## PowerShell


```powershell
Write-Host "Hello, world!"
```


## Prolog


```prolog
main:- write('Hello, world!'), nl.
```


## پایتون ۲


```python
print "Hello, world!"
```


## پایتون ۳


```python
print("Hello, world!")
```


## Pythonect


```python
"Hello, world!" -> print
```


## R

```r
cat('Hello, world!\n')
```


## Racket

Trivial "hello world" program:

```racket
"Hello, world!"
```

Running this program produces `"Hello, World!"`. More direct version:

```racket
# lang racket
(display "Hello, world!")
```


A "hello world" سرور وب using Racket's `web-server/insta` language:

```racket
# lang web-server/insta
(define (start request) (response/xexpr '(html (body "Hello, world"))))}
```


## REXX

```rexx
say Hello, world!
```


## RPL


```lisp
<<"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!"
```
یا بدون پرش به سر خط:
```ruby
print "Hello, world!"
```


## Rust


```rust
fn main() {
   println!("Hello, world!");
 }
```


## Scala


```scala
object HelloWorld extends App {
  println("Hello, world!")
}
```


## Scheme


```scheme
(display "Hello, world!")
```


## Shell


```bash
echo Hello, world!
```


## Simula

```
Begin
 OutText ("Hello, world!");
 Outimage;
End;
```


## Smalltalk


```smalltalk
Transcript show: 'Hello, world!'.
```


## SNOBOL

```snobol
OUTPUT = 'Hello, world!'
END
```


## Speakeasy

به صورت عبارات تعاملی(interactive):
```
"Hello, world!"
```
به عنوان برنامه:
```
program hello
  "Hello, world!"
end
```


## SQL


```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.
```


## Smalltalk


```smalltalk
Transcript show: 'Hello, world!'.
```


## Stata


```smalltalk
display "Hello, world!"
```


## Tcl


```tcl
puts "Hello, world!"
```


## TI-BASIC

```ti
Disp "Hello, world!"
```


## UnrealScript

```
Log("Hello, world!");
```


## Vala


```vala
void main ()
{
    print ("Hello, world!\n");
}
```


## Visual Basic


```vb
MsgBox "Hello, world!"
```


## Visual Basic.NET


```vbnet
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
```


## Whitespace

 S&#32;S&#32;S&#32;T&#9;S&#32;S&#32;T&#9;S&#32;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;S&#32;T&#9;S&#32;T&#9;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;T&#9;T&#9;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;T&#9;T&#9;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;T&#9;T&#9;T&#9;T&#9;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;S&#32;T&#9;T&#9;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;S&#32;S&#32;S&#32;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;T&#9;S&#32;T&#9;T&#9;T&#9;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;T&#9;T&#9;T&#9;T&#9;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;T&#9;S&#32;S&#32;T&#9;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;T&#9;T&#9;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;T&#9;S&#32;S&#32;T&#9;S&#32;S&#32;L&#10;T&#9;L&#10;S&#32;S&#32;S&#32;S&#32;S&#32;T&#9;S&#32;S&#32;S&#32;S&#32;T&#9;L&#10;T&#9;L&#10;S&#32;S&#32;L&#10;L&#10;L&#10;

## پیوند به بیرون

* 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.

رده:برنامه‌نویسی
رده:مقاله‌های با مثال کد سی شارپ