„Hello, World!“

Hello World“ je počítačový program, ktorý na displej vypíše „Hello world!“. V mnohých programátorských knihách sa používa ako prvý príklad programu. Typicky je to jeden z najjednoduchších programov možných v danom jazyku.

Program Hello, World! v rôznych programovacích jazykoch môže vyzerať napríklad takto:

Ada

 with TEXT_IO;
 
 procedure HELLO is
 begin
    TEXT_IO.PUT_LINE ("Hello, world!");
 end HELLO;

ABAP

REPORT Hello_world.
Write: 'Hello, world!'.

BASIC

 10 PRINT "Hello, world!"
 20 END

Visual Basic.NET

 Imports System
 Namespace HelloWorld
   Module Hello
     Sub Main()
       Console.WriteLine("Hello World!")
       Console.ReadLine()
     End Sub
   End Module
 End Namespace

C

 #include <stdio.h>
 
 int main(void) {
     printf("Hello, world!\n");
     return 0;
 }

C++

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

C#

class HelloWorld
{
    static void Main()
    {
        System.Console.WriteLine("Hello, World!");
    }
}

COBOL

    IDENTIFICATION DIVISION.
    PROGRAM-ID.     HELLO-WORLD.
 
    ENVIRONMENT DIVISION.
 
    DATA DIVISION.
 
    PROCEDURE DIVISION.
    DISPLAY "Hello, world!".
    STOP RUN.

Fortran

       PROGRAM HALLO
       PRINT *, "Hello, world!"
       END PROGRAM

Java

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

Lua

print("Hello, world!")

Modula-2

MODULE Hello;

FROM Terminal2 IMPORT WriteLn; WriteString;

BEGIN
  WriteString("Hello, world!");
  WriteLn;
END Hello;

Pascal

 begin
   Writeln('Hello, world!');
 end.

Perl

 print "Hello, world!\n";

Python

Pre verziu Pythonu 2.7 a staršiu:

 print "Hello, world!\n"

Pre verziu Pythonu 3.0 a novšiu:

 print("Hello, world!\n")

PHP

 <?php
   echo "Hello, world!";
   print "Hello, world!";
 ?>

Seed7

$ include "seed7_05.s7i";

const proc: main is func
  begin
    writeln("Hello, world!");
  end func;

Smalltalk

 Transcript show: 'Hello, world!'; cr

Swift

print("Hello, World!")

GML

 show_message("Hello world!");
 // alebo
 draw_text(x, y, "Hello world!");

Externé odkazy

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.