[ 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 ]

C:
pasted 1 hour ago:
1
2
3
4
5
6
#include <stdio.h>

void main() {
  char *test = "hello world";
  printf("%s\n", test);
}
view (6 lines, 1 line of output)
pasted 1 hour ago:
1
2
3
4
5
6
#include <stdio.h>

void main() {
  char *test = "hello world";
  printf("%s\n", test);
}
view (6 lines, 1 line of output)


C++:
pasted 7 hours ago:
1
2
3
#include <iostream>

int main () {cout << "Hello, World";}
view (3 lines, 1 line of output)
pasted 8 hours ago:
1
2
3
4
5
6
#include <stdio.h>

int main (void)
{
    printf("hello, world\n");
}
view (6 lines, 1 line of output)


D:
pasted on Jan 10:
1
2
3
4
5
int main()
{
printf("hello world!");
return 0;
}
view (5 lines, 1 line of output)
pasted on Nov 29:
1
2
3
4
5
int main()
{
printf("hello world!");
return 0;
}
view (6 lines, 1 line of output)


Haskell:
pasted 11 hours ago:
1
2
3
4
5
6
7
quicksort [] c = []
quicksort(p:xs) c = (quicksort (filter (\x -> c x p == LT) xs) c) ++ [p] ++ (quicksort (filter (\x -> c x p == GT) xs) c)

numbers = [ 645.32, 37.40, 76.30, 5.40, -34.23, 1.11, -34.94, 23.37, 635.46, -876.22, 467.73, 62.26 ] 

main = do
    putStrLn "Hello World"
view (7 lines, 1 line of output)
pasted on Apr 24:
1
2
3
4
5
6
7
quicksort [] c = []
quicksort(p:xs) c = (quicksort (filter (\x -> c x p == LT) xs) c) ++ [p] ++ (quicksort (filter (\x -> c x p == GT) xs) c)

numbers = [ 645.32, 37.40, 76.30, 5.40, -34.23, 1.11, -34.94, 23.37, 635.46, -876.22, 467.73, 62.26 ] 

main = do
    putStrLn "Hello World"
view (8 lines, 1 line of output)


Lua:
pasted on Apr 26:
1
print("Hello World")
view (1 line, 1 line of output)
pasted on Apr 26:
1
print ("Hello World")
view (1 line, 1 line of output)


OCaml:
pasted on Mar 5:
1
Printf.printf "Hello world!";;
view (1 line, 1 line of output)
pasted on Nov 9:
1
print_string "Hello world!\n";;
view (1 line, 1 line of output)


PHP:
pasted on Apr 22:
1
2
3
4
5
<?php

print "Hello World!";

?>
view (5 lines, 1 line of output)
pasted on Apr 22:
1
<?php echo 'hello world';
view (1 line, 1 line of output)


Perl:
pasted on Apr 24:
1
print "Hello World!\n";
view (1 line, 1 line of output)
pasted on Apr 20:
1
print "Hello, world!";
view (1 line, 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
print("hello world")
view (1 line, 1 line of output)


Ruby:
pasted on Apr 25:
1
puts "Hello World!"
view (1 line, 1 line of output)
pasted on Apr 24:
1
print "Hello World"
view (1 line, 1 line of output)


Scheme:
pasted on Apr 11:
1
(display "Hello World")
view (1 line, 1 line of output)
pasted on Mar 27:
1
(display "Hello, World\n")
view (1 line, 1 line of output)