[ 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 2 hours ago:
1
2
3
4
5
6
#include <stdio.h>

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


C++:
pasted 55 minutes 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)
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 Jun 30:
1
2
3
4
5
6
7
8
import std.stdio;

void main()
{   int v;
    v = 9;
    writefln("Hello World!");
    //writefln("v is set to %i",v);
}
view (8 lines, 1 line of output)
pasted on Jun 30:
1
2
3
4
5
6
7
8
import std.stdio;

void main()
{   int v;
    //v = 9;
    writefln("Hello World!");
    //writefln("v is set to %i",v);
}
view (8 lines, 1 line of output)


Haskell:
pasted on Jul 28:
1
2
3
4
import Control.Monad
main :: IO ()
main = do
    forM_ "Hello, world" putChar
view (4 lines, 1 line of output)
pasted on Jul 23:
1
2
3
4
import Control.Monad
main :: IO ()
main = do
    forM_ "Hello, world" putChar
view (4 lines, 1 line of output)


Lua:
pasted on Jul 31:
1
print ("Hello World")
view (1 line, 1 line of output)
pasted on Jul 29:
1
print "hello world\n"
view (1 line, 2 lines of output)


OCaml:
pasted on Jul 14:
1
print_string "Hello world!\n";;
view (1 line, 1 line of output)
pasted on Jul 12:
1
print_string "Hello world!\n";;
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
<?php echo 'hello world!'; ?>
view (1 line, 1 line of output)
pasted on Jul 31:
1
<?php echo 'Hello, world'; ?>
view (1 line, 1 line of output)


Perl:
pasted on Jul 31:
1
2
3
my %sku = "123";

print "Hello, world\n";
view (3 lines, 1 line of output)
pasted on Jul 30:
1
print "Hello World\n";
view (1 line, 1 line of output)


Python:
pasted 38 minutes ago:
1
print "hello world"
view (1 line, 1 line of output)
pasted 1 hour ago:
1
print "Hello World"
view (1 line, 1 line of output)


Ruby:
pasted 4 hours ago:
1
2
3
4
def nya
puts "Hello world!"
end
nya()
view (4 lines, 1 line of output)
pasted 4 hours ago:
1
2
3
4
def nya
puts "Hello world!"
end
nya
view (4 lines, 1 line of output)


Scheme:
pasted on Jul 30:
1
(display "Hello World")
view (1 line, 1 line of output)
pasted on Jun 23:
1
(display "Hello World!")
view (1 line, 1 line of output)