[ create a new paste ] login | about

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

C:
pasted 7 hours ago:
1
2
3
4
5
#include <stdio.h>
void main() {

printf("hello world");
}
view (5 lines, 1 line of output)
pasted 15 hours ago:
1
2
3
4
5
#include <stdio.h>
void main() {

printf("hello world");
}
view (5 lines, 1 line of output)


C++:
pasted 9 hours ago:
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

// main() is where program execution begins.
int main() {
   cout << "Hello World"; // prints Hello World
   return 0;
}
view (8 lines, 1 line of output)
pasted 9 hours ago:
1
2
3
4
5
6
#include <iostream>

int main(){
    std::cout << "Hello world" << std::endl;
return 0;
}
view (6 lines, 1 line of output)


Haskell:
pasted on Aug 15:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)
pasted on Jul 16:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)


Lua:
pasted on Aug 12:
1
print("Hello World!")
view (1 line, 1 line of output)
pasted on Aug 9:
1
print("Hello world");
view (1 line, 1 line of output)


OCaml:
pasted on Aug 18:
1
print_string "Hello, world"
view (1 line, 1 line of output)
pasted on Aug 6:
1
print_string "Hello, world"
view (1 line, 1 line of output)


PHP:
pasted 12 hours ago:
1
2
3
<?
print "Hello world!";
?>
view (3 lines, 1 line of output)
pasted 15 hours ago:
1
2
<?php
echo "hello world";
view (2 lines, 1 line of output)


Perl:
pasted on Aug 15:
1
2
printf STDOUT "Hello World!\n";
printf STDOUT chr(0)
view (2 lines, 2 lines of output)
pasted on Aug 15:
1
2
printf STDOUT "Hello World!\n";
printf STDOUT chr(0)
view (2 lines, 2 lines of output)


Python:
pasted 3 hours ago:
1
print('Hello World')
view (1 line, 1 line of output)
pasted 4 hours ago:
1
print('hello world')
view (1 line, 1 line of output)


Ruby:
pasted 12 hours ago:
1
print "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 Aug 5:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on Aug 3:
1
2
(define main "Hello, world!")
(display main)
view (2 lines, 1 line of output)