[ 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 20 minutes ago:
1
2
3
4
5
6
7
#include <stdio.h>
int main()
{
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
view (7 lines, 1 line of output)
pasted 44 minutes ago:
1
2
3
4
5
6
7
#include <stdio.h>
int main()
{
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
view (7 lines, 1 line of output)


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

// main() is where program execution begins.

int main() {
   cout << "Hello World"; // prints Hello World
   return 0;
}
view (9 lines, 1 line of output)
pasted 3 hours ago:
1
2
3
4
5
6
7
8
9
10
#include <iostream>

using namespace std;

int main() 
{ 
    cout << "Hello, world!" << endl;

    return 0; 
}
view (10 lines, 1 line of output)


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

int main(string[] args)
{
    writefln("%s", "Hello World!");
    return (0);
}
view (7 lines, 1 line of output)
pasted on Jul 27:
1
2
3
4
5
6
7
8
import std.stdio;

int main()
{
	writefln("Hello world");
	
	return 0;
}
view (8 lines, 1 line of output)


Haskell:
pasted on Aug 5:
1
2
main :: IO ()
main = putStrLn "Hello World"
view (2 lines, 1 line of output)
pasted on Jul 7:
1
2
main :: IO ()
main = putStrLn "Hello World"
view (2 lines, 1 line of output)


Lua:
pasted yesterday:
1
print("hello world")
view (1 line, 1 line of output)
pasted yesterday:
1
print("hello world")
view (1 line, 1 line of output)


OCaml:
pasted on Jun 18:
1
print_endline "Hello, world!"
view (1 line, 1 line of output)
pasted on Mar 5:
1
Printf.printf "Hello world!";;
view (1 line, 1 line of output, 99 comments)


PHP:
pasted 8 hours ago:
1
2
3
<?php 
print("Hello World!"); 
?>
view (3 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
<?php

    echo "hello world";
?>
    
view (5 lines, 1 line of output)


Perl:
pasted on Aug 14:
1
print ('Hello, World!')
view (1 line, 1 line of output)
pasted on Aug 12:
1
print("hello, world");
view (1 line, 1 line of output)


Python:
pasted yesterday:
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 Aug 12:
1
puts "Hello World"
view (1 line, 1 line of output)
pasted on Aug 4:
1
puts "Hello World"
view (1 line, 1 line of output)


Scheme:
pasted on Aug 4:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on Jul 31:
1
2
3
4
;The first program
(begin
  (display "Hello, World!")
  (newline))
view (4 lines, 1 line of output)