Difference between revisions of "Hello world"

From CodeCodex

(Implementations)
(Seed7)
Line 174: Line 174:
 
[[Category:Seed7]]
 
[[Category:Seed7]]
 
[[Category:Common Lisp]]
 
[[Category:Common Lisp]]
 +
[[Category:Fortran]]

Revision as of 18:21, 28 July 2006

Implementations

C

#include <stdio.h>

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

Common Lisp

(write-line "Hello, World!\n")

..or..

(defun main ()
  (write-line "Hello, World!")
  0)

ASP

<% Response.Write("Hello World!") %>

C++

#include <iostream>

int main()
{
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

OR

#include <iostream>
using namespace std;

int main()
{
    cout << "Hello, World!" << endl;
    return 0;
}

x86 Assembler

The source should be compiled and linked with Turbo Assembler.

    .model tiny

    .data
message    db    'Hello, World!'
    
    .code
    org 100h

start:
    mov ah,9
    mov dx,offset message
    int 21h

    ret
    end start

Fortran

PROGRAM HelloWorld
WRITE(*,*)"Hello, World!"
END PROGRAM

Java

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

BASIC

print "Hello World!"

OCaml

# print_endline "Hello world!";;
Hello world!
- : unit = ()

Pascal

program HelloWorld;

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

Perl

As PL file:

print "Hello World";

As CGI file:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<H1>Hello World</H1>";

PHP

<?php
    echo 'Hello, world!';
?>
#or use short-hand echoing, syntaxed as such:
<?="Hello, world!"?>

Python

print "Hello, World!"

Rexx

/* */
say "Hello, World!"

Ruby

print("Hello, World!")

Seed7

$ include "seed7_05.s7i";
 
const proc: main is func
  begin
    writeln("Hello, world!");
  end func;