[ 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
7
8
#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello world!\n");
    return 0;
}
view (8 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
#include <stdio.h> 
int main() 
{ 
  printf("Hello world!"); 
  return 0; 
}
view (6 lines, 1 line of output)


C++:
pasted yesterday:
1
2
3
4
5
6
7
#include <iostream>

int main()
{
    std::cout << "Hello World";

}
view (7 lines, 1 line of output)
pasted yesterday:
1
2
3
4
#include <iostream>
int main(){
    std::cout << "Hello World";
}
view (4 lines, 1 line of output)


D:
pasted on Aug 30:
1
2
3
4
5
6
import std.stdio;

void main()
{
    writefln("Hello, World!");
}
view (6 lines, 1 line of output)
pasted on Aug 20:
1
2
3
4
5
6
import std.stdio;

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


Haskell:
pasted on Aug 20:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)
pasted on Aug 7:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)


Lua:
pasted on Sep 21:
1
print("Hello world")
view (1 line, 1 line of output)
pasted on Sep 18:
1
print("Hello World!")
view (1 line, 1 line of output)


OCaml:
pasted on Jul 26:
1
print_endline("hello world")
view (1 line, 1 line of output)
pasted on Jul 26:
1
2
print_endline ("hello world")
(* imprime hello world *)
view (2 lines, 1 line of output)


PHP:
pasted on Sep 21:
1
2
3
4
<?php
  $hello="Hello World";
  print ($hello);
?>
view (4 lines, 1 line of output)
pasted on Sep 18:
1
<?php echo "Hello World";
view (1 line, 1 line of output)


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


Python:
pasted yesterday:
1
print("hello, world!")
view (1 line, 1 line of output)
pasted yesterday:
1
2
3
4
"""
This is a multi line
com"""
print 'Hello, world'
view (4 lines, 1 line of output)


Ruby:
pasted on Sep 21:
1
2
3
4
5
6
7
def bar(n, &block)
  block.call
end

bar(5) {
  puts "hello, world"
}
view (7 lines, 1 line of output)
pasted on Sep 21:
1
2
3
4
5
6
7
def bar(&block)
  block.call
end

bar do
  puts "hello, world"
end
view (7 lines, 1 line of output)


Scheme:
pasted on Sep 15:
1
2
3
(begin
  (display "Hello, World!")
  (newline))
view (3 lines, 1 line of output)
pasted on Aug 20:
1
2
3
(begin
  (display "Hello, World!")
(newline))
view (3 lines, 1 line of output)