[ 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>

void main()
{
    printf("Hello World!");
}
view (6 lines, 1 line of output)
pasted 3 hours 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)


C++:
pasted 6 hours ago:
1
2
3
4
5
6
#include <iostream>

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

 int main(void) 
 {
 printf("hello world!\n");
 return 0;
 }
view (7 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 Sep 27:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)
pasted on Aug 20:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)


Lua:
pasted on Oct 7:
1
print("Hello, world")
view (1 line, 1 line of output)
pasted on Oct 7:
1
2
3
4
5
6
str = "Hello World"
print(str)
--[[
HELLO WORLD
]]
-- HELLO WORLD
view (6 lines, 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 2 hours ago:
1
2
3
4
5
<?

echo "Hello World";  //This is echo

?>
view (5 lines, 1 line of output)
pasted on Oct 16:
1
2
3
4
5
<?php
$hello = "Hello World!";
echo $hello;
echo "\n";
?>
view (5 lines, 1 line of output)


Perl:
pasted on Oct 12:
1
print "hello World"
view (1 line, 1 line of output)
pasted on Oct 11:
1
print "hello World"
view (1 line, 1 line of output)


Python:
pasted 4 hours ago:
1
print("hello world")
view (1 line, 1 line of output)
pasted 5 hours ago:
1
2
3
4
5
6
7
8
9
# Hello World program in Python
import re
    
print "Hello World!\n"
sentence = 'beamcraft:  success'
pattern = re.compile(r'\bbeamcraft:\Ssuccess')
matches = pattern.finditer(sentence)
for match in matches:
    print(match)
view (9 lines, 2 lines of output)


Ruby:
pasted yesterday:
1
puts "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 Sep 26:
1
(display "Hello, world!")
view (1 line, 1 line of output)
pasted on Sep 15:
1
2
3
(begin
  (display "Hello, World!")
  (newline))
view (3 lines, 1 line of output)