[ 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 29 minutes 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 1 hour ago:
1
2
3
4
5
6
#include <stdio.h>
int main()
{
     printf("hello world \n");
     return 0;
}
view (6 lines, 1 line of output)


C++:
pasted 31 minutes ago:
1
2
3
4
5
6
7
8
9
// This program justs displays a string and exits, variation 2
#include <iostream>
 
int main() {
  std::cout << "Hello World!";
  std::cout << std::endl;

  return 0;
}
view (9 lines, 1 line of output)
pasted 32 minutes ago:
1
2
3
4
5
6
7
8
#include<iostream>
using namespace std;

int main(){
cout<<"hello world\n";
return 0;

}
view (8 lines, 1 line of output)


D:
pasted on Jan 10:
1
2
3
4
5
int main()
{
printf("hello world!");
return 0;
}
view (5 lines, 1 line of output)
pasted on Nov 29:
1
2
3
4
5
int main()
{
printf("hello world!");
return 0;
}
view (6 lines, 1 line of output)


Haskell:
pasted on Feb 18:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)
pasted on Feb 9:
1
main = putStrLn "hello world"
view (1 line, 1 line of output)


Lua:
pasted 6 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)


OCaml:
pasted on Nov 9:
1
print_string "Hello world!\n";;
view (1 line, 1 line of output)
pasted on Nov 5:
1
print_string "hello, world"
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
2
3
4
5
6
7
8
9
10
11
<?php
function function1()
{
function function2()
{
echo "Hello World ";
}
}
function1();
function2();
?>
view (11 lines, 1 line of output)
pasted on Feb 19:
1
2
3
4
5
6
7
8
9
10
11
<?php
function function1()
{
function function2()
{
echo "Hello World ";
}
}
function1();
function2();
?>
view (11 lines, 1 line of output)


Perl:
pasted yesterday:
1
2
3
#!/usr/local/bin/perl
print "Hello World\n";
@array = (10,12,45);
view (3 lines, 1 line of output)
pasted yesterday:
1
2
#!/usr/local/bin/perl
print "Hello World\n";
view (2 lines, 1 line of output)


Python:
pasted 7 minutes ago:
1
print("hello world");
view (1 line, 1 line of output)
pasted 32 minutes ago:
1
print "Hello, world!"
view (1 line, 1 line of output)


Ruby:
pasted 5 hours ago:
1
puts 'hello, world!'
view (1 line, 1 line of output)
pasted on Feb 18:
1
print("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 Feb 17:
1
2
3
4
(define (hello-world)
   (display "Hello World"))

(hello-world)
view (4 lines, 1 line of output)