[ 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:
pasted 37 minutes ago:
1
2
3
4
5
#include <stdio.h>
void main()
{
	printf("Hello World ");
}
view (5 lines, 1 line of output)
pasted 40 minutes ago:
1
2
3
4
5
#include <stdio.h>
void main()
{
	printf("Hello World ");
}
view (5 lines, 1 line of output)


C++:
pasted 31 minutes 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)
pasted 43 minutes ago:
1
2
3
4
5
6
7
#include <iostream>
 using namespace std;
int main()
{
  cout << "Hello World!"<<endl;
  return 0;
}
view (7 lines, 1 line of output)


D:
pasted on Jul 18:
1
2
3
4
5
6
import std.stdio;

void main()
{
    writef("Hello, world");
}
view (6 lines, 1 line of output)
pasted on Jun 17:
1
2
3
4
5
import std.stdio;

void main() {
    writefln("Hello, World!");
}
view (5 lines, 1 line of output)


Haskell:
pasted on Jul 18:
1
main = putStrLn "Hello World!"
view (1 line, 1 line of output)
pasted on Jul 17:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import Data.List
import System.Random
import Data.Ord

type Point     = (Float,Float)
type Color     = (Int,Int,Int)
type Polygon   = [Point]
type Person    = [Int]
type Link      = [Point]
type Placement = [(Point,Person)]

type EnergyFunction a              = a -> Int
type TemperatureFunction           = Int -> Int -> Float
type TransitionProbabilityFunction = Int -> Int -> Float -> Float
type MotionFunction a              = StdGen -> a -> (StdGen,a)

main = do 
  putStr "Hello World! \n"
view (18 lines, 1 line of output)


Lua:
pasted yesterday:
1
print("Hello World!")
view (1 line, 1 line of output)
pasted yesterday:
1
print("Hello World!")
view (1 line, 1 line of output)


OCaml:
pasted on Jun 5:
1
 print_endline "Hello world!";;
view (1 line, 1 line of output)
pasted on Jun 5:
1
print_string "Hello world!\n";;
view (1 line, 1 line of output)


PHP:
pasted 1 hour ago:
1
<?php echo "Hello World"; ?>
view (1 line, 1 line of output)
pasted 1 hour ago:
1
2
3
<?php
  echo "Hello World";
?>
view (3 lines, 1 line of output)


Perl:
pasted 11 hours ago:
1
print "Hello World!\n";
view (1 line, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/perl

print "Hello World!\n";
$res = "default.0                        0           (0    ) 8027         1059452      LOCAL     low ----
            default-switch.3                 3           (0    ) 8006         1120824      LOCAL     low ----
    default.0                        0           (0    ) 8027         1059452      LOCAL     low ----";
 if ($res=~m/$temp1/gi){
          $res = $';
           $res=~m/\d+/g;
         # print "$res"
 }
view (11 lines, 1 line of output)


Python:
pasted 5 hours ago:
1
print 'hello world'
view (1 line, 1 line of output)
pasted 5 hours ago:
1
2
3
def main():
 print "Hello World"
main()
view (3 lines, 1 line of output)


Ruby:
pasted yesterday:
1
puts "hello world";
view (1 line, 1 line of output)
pasted yesterday:
1
puts 'Hello world'
view (1 line, 1 line of output)


Scheme:
pasted on Jul 22:
1
2
3
4
(display "Hello World")
(newline)
(cons 1 '()) 
(define test (list 1 1 2 3 5))
view (4 lines, 1 line of output)
pasted on Jul 22:
1
(display "Hello, World!")
view (1 line, 1 line of output)


Tcl:
pasted on Jul 16:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)
pasted on Jul 11:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)