[ create a new paste ] login | about

Listed below are example programs that print "hello world", written in the following languages:
[ C | C++ | D | Haskell | Lua | OCaml | PHP | Perl | Python | Ruby | Scheme | Tcl ]

C:
fysteven - pasted 56 minutes ago:
1
2
3
4
#include <stdio.h>
void main() {
printf("hello world");
}
view (4 lines, 1 line of output)
pasted 1 hour ago:
1
2
3
4
5
6
7
8
#include<stdio.h>

int main(void)
{
    printf("Hello World!\n");

    return 0;
}
view (8 lines, 1 line of output)


C++:
pasted 1 hour ago:
1
2
3
4
5
6
7
#include<iostream>
int main()
{
    cout<<"hello world!"<<endl;

    return 0;
}
view (7 lines, 1 line of output)
pasted 3 hours ago:
1
2
3
4
5
6
7
#include <iostream>
 
int main()
{
  std::cout << "Hello World!" << std::endl;
  return 0;
}
view (7 lines, 1 line of output)


D:
pasted on Apr 16:
1
2
3
4
5
int main()
{
printf ("Hello world");
return 0;
}
view (5 lines, 1 line of output)
pasted on Apr 12:
1
2
3
4
5
int main()
{
printf ("Hello world");
return 0;
}
view (5 lines, 1 line of output)


Haskell:
pasted on Apr 12:
module Main where

-- we are going to calculate pagerank today

type Vertex = Integer
type Edge = (Vertex, Vertex)

type AssocList = [Edge]

data DigraphVertex = DigraphVertex { source :: Vertex , dest :: [Vertex] }

type Digraph = [DigraphVertex]

{-
insert :: AssocList -> Digraph -> (AssocList, Digraph)
-- nothing left to insert
insert [] ds = ([], ds)
-- reached the end of ds, unique item
-- make a new entry for x
insert (x:xs) [] = insert xs
-}


enDigraph :: AssocList -> Digraph
enDigraph [] = []
enDigraph x = map (\(a,b) -> DigraphVertex {source = a, dest = [b]} ) x




data PageRankGraph = PageRankGraph { reversed :: DigraphVertex }



main = putStrLn "Hello, World!"
view (35 lines, 1 line of output)
pasted on Apr 12:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module Main where

type Vertex = Integer
type Edge = (Vertex, Vertex)

type AssocList = [Edge]

data DigraphVertex = DigraphVertex { source :: Vertex , dest :: [Vertex] }



type Digraph = [DigraphVertex]



main = putStrLn "Hello, World!"
view (16 lines, 1 line of output)


Lua:
pasted on Apr 17:
1
    print "Hello, World!";
view (2 lines, 1 line of output)
pasted on Apr 16:
1
print("Hello World")
view (1 line, 1 line of output)


OCaml:
pasted on Mar 7:
1
print_string "Hello World!\n";;
view (1 line, 1 line of output)
pasted on Feb 20:
1
 print_endline "Hello, world!"
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
2
3
<?php
echo "Hello world";
?>
view (3 lines, 1 line of output)
pasted on Apr 19:
1
2
3
<?php
echo'Hello World!';
?>
view (3 lines, 1 line of output)


Perl:
pasted on Apr 16:
1
2
3
4
#!/usr/bin/perl

# This will print "Hello, World"
print "Hello, world\n";
view (4 lines, 1 line of output)
pasted on Apr 15:
1
print "Hello world"    
view (1 line, 1 line of output)


Python:
pasted 4 minutes ago:
1
print "hello world"
view (1 line, 1 line of output)
pasted 14 minutes ago:
1
print "hello, world"
view (1 line, 1 line of output)


Ruby:
pasted 9 minutes ago:
1
puts "hello world"
view (1 line, 1 line of output)
pasted on Apr 17:
1
print "Hello, World!\n"
view (1 line, 1 line of output)


Scheme:
pasted on Apr 9:
1
(display "Hello World!")
view (1 line, 1 line of output)
pasted on Apr 4:
1
2
3
4
5
6
7
(define hello-world
  (lambda ()
    (display "Hello, World!")
    (newline)
    ))

(hello-world)
view (8 lines, 1 line of output)


Tcl:
pasted on Apr 12:
1
2
3
4
puts -nonewline "Hello world!"
set a 10
expr $a + 1
set y [expr $a + 1]
view (4 lines, 1 line of output)
pasted on Mar 28:
1
2
3
4
puts -nonewline "Hello world!"
set a 10
expr $a + 1
set y [expr $a + 1]
view (4 lines, 1 line of output)