[ create a new paste ] login | about

Listed below are example programs that print "hello world", written in the following languages:
[ C | C++ | Haskell | Lua | OCaml | PHP | Perl | Python | Ruby | Scheme ]

C:
pasted 7 hours ago:
1
2
3
4
5
6
#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
view (6 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
view (6 lines, 1 line of output)


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

int main(){
cout<<"hello world";
return 0;
}
view (7 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
8
// Your First C++ Program

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;
}
view (8 lines, 1 line of output)


Haskell:
pasted yesterday:
1
2
3
4
module Main where

main :: IO ()
main = putStr "Hello world"
view (4 lines, 1 line of output)
pasted on Nov 7:
1
2
3
4
module Main where

main :: IO ()
main = putStr "Hello world"
view (4 lines, 1 line of output)


Lua:
pasted on Nov 15:
1
print("Hello, World")
view (1 line, 1 line of output)
pasted on Oct 30:
1
2
print ("Hello World!")
hoge = 10
view (2 lines, 1 line of output)


OCaml:
pasted on Nov 14:
1
print_endline "hello, world!"
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
2
3
4
5
6
7
<?php
function writeMsg() {
  echo "Hello world!";
}

writeMsg(); // call the function
?>
view (7 lines, 1 line of output)
pasted yesterday:
1
2
3
<?php
echo 'Hello, World';
?>
view (3 lines, 1 line of output)


Perl:
pasted on Nov 20:
1
2
3
#!/usr/bin/perl

print 'Hello, world!';
view (3 lines, 1 line of output)
pasted on Nov 16:
1
print "hello world \n";
view (1 line, 1 line of output)


Python:
pasted 3 hours ago:
1
print("hello world")
view (1 line, 1 line of output)
pasted 5 hours ago:
1
print('hello world')
view (1 line, 1 line of output)


Ruby:
pasted on Nov 24:
1
puts 'Hello world'
view (1 line, 1 line of output)
pasted on Oct 27:
1
puts "hello world"
view (1 line, 1 line of output)


Scheme:
pasted on Oct 5:
1
(display "Hello, World!")
view (1 line, 1 line of output, 1 comment)
pasted on Aug 10:
1
(display "Hello world!")
view (1 line, 1 line of output)