[ 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 6 minutes ago:
1
2
3
4
5
6
#include <stdio.h>
int main()
{
     printf("hello world \n");
     return 0;
}
view (6 lines, 1 line of output)
pasted 3 hours ago:
1
2
3
4
5
6
#include <stdio.h>
int main()
{
     printf("hello world \n");
     return 0;
}
view (6 lines, 1 line of output)


C++:
pasted 33 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)
pasted 50 minutes ago:
1
2
3
4
5
6
7
8
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
puts("Hello World!");
return EXIT_SUCCESS;
}
view (8 lines, 1 line of output)


D:
pasted on Apr 17:
1
2
3
4
int main(){
printf("Hello World!");
return 0;
}
view (4 lines, 1 line of output)
pasted on Apr 15:
1
2
3
4
5
import std.stdio;

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


Haskell:
pasted on May 26:
1
2
main :: IO ()
main = putStrLn "Hello World!\n"
view (2 lines, 2 lines of output)
pasted on May 24:
1
2
3
module Main(main) where

main = putStrLn "Hello, world!"
view (3 lines, 1 line of output)


Lua:
pasted 9 hours ago:
1
print("hello world")
view (1 line, 1 line of output)
pasted on May 27:
1
2
3
4
5
function hello()
  print("Hello World!")
end

hello()
view (5 lines, 1 line of output)


OCaml:
pasted on May 1:
1
let () = Printf.printf "Hello world!\n"
view (1 line, 1 line of output)
pasted on Apr 13:
1
print_endline "Hello, World!"
view (1 line, 1 line of output)


PHP:
pasted on May 27:
1
2
3
4
5
6
7
8
<?php
class MyProgram {
	public static function main() {
		System.out.print("Hello, world!");
	}
}

MyProgram::main();
view (8 lines, 1 line of output)
pasted on May 27:
1
<?echo "Hello world";?>
view (1 line, 1 line of output)


Perl:
pasted on May 27:
1
print("hello world")
view (1 line, 1 line of output)
pasted on May 27:
1
print "Hello World\n";
view (1 line, 1 line of output)


Python:
pasted 2 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 yesterday:
1
2
3
4
5
def hi
puts "hello world"
end

hi
view (5 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
def hi
puts "hello world"
end

hi()
view (5 lines, 1 line of output)


Scheme:
pasted on May 24:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on May 8:
1
(display "Hello, World!")
view (1 line, 1 line of output)


Tcl:
pasted on May 5:
1
2
set hello "Hello, World!"
puts -nonewline $hello ;
view (2 lines, 1 line of output)
pasted on Jan 29:
1
2
set hello "Hello, World!"
puts -nonewline $hello ;
view (2 lines, 1 line of output)