[ 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 1 hour ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <stdlib.h>

main() {

    printf("Hello World!\n");

    exit(0);

}
view (10 lines, 1 line of output)
pasted 1 hour ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
#include <stdlib.h>

main() {

    printf("Hello World!\n");

    exit(0);

}
view (10 lines, 1 line of output)


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

int main(){
cout<< "Hello World!";

return 0;
}
view (8 lines, 1 line of output)
pasted 4 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 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:
anekludov@inbox.ru - pasted on Jun 28:
1
2
main :: IO ()
main = putStrLn "Hello, World!"
view (2 lines, 1 line of output)
pasted on Jun 28:
1
2
main :: IO ()
main = putStrLn "Hello, World!"
view (2 lines, 1 line of output)


Lua:
pasted on Jun 28:
1
print ("hello world")
view (1 line, 1 line of output)
pasted on Jun 24:
1
print("hello world")
view (1 line, 1 line of output)


OCaml:
TT22 - pasted on Jun 4:
1
2
3
let hello = "Hello" ;;
let world = "world" ;;
Printf.printf "%s %s!" hello world ;;
view (3 lines, 1 line of output)
TT22 - pasted on Jun 4:
1
Printf.printf "Hello world!" ;;
view (1 line, 1 line of output)


PHP:
pasted 13 minutes ago:
1
2
3
<?php
echo "hello world";
?>
view (3 lines, 1 line of output)
pasted 30 minutes ago:
1
2
3
<?php
    echo"hello world";
?>
view (3 lines, 1 line of output)


Perl:
pasted yesterday:
1
2
3
4
5
6
7
print "Hello, world\n";

=begin comment
This is all part of multiline comment.
You can use as many lines as you like
These comments will be ignored by the 
compiler until the next =cut is encountered.
view (7 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
8
print "Hello, world\n";

=begin comment
This is all part of multiline comment.
You can use as many lines as you like
These comments will be ignored by the 
compiler until the next =cut is encountered.
=cut
view (8 lines, 1 line of output)


Python:
pasted 5 hours ago:
1
print("hello world")
view (1 line, 1 line of output)
pasted yesterday:
1
print "Hello World"
view (1 line, 1 line of output)


Ruby:
pasted on Jun 28:
1
print "Hello World!"
view (1 line, 1 line of output)
pasted on Jun 23:
1
puts "Hello World"
view (1 line, 1 line of output)


Scheme:
pasted yesterday:
1
(display "hello world")
view (1 line, 1 line of output)
pasted on Jun 20:
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)