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

int main( int argc, char *argv[])
{
  printf("hello world\n");
  return 0;
}
view (8 lines, 1 line of output)
pasted yesterday:
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 4 hours ago:
1
2
3
4
5
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
}
view (5 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
8
9
10
#include <iostream>

using namespace std;

int main()
{
    cout<<"Hello World";

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


Haskell:
pasted on Jul 16:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)
pasted on Jul 13:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)


Lua:
pasted on Jul 19:
1
print("Hello, world!")
view (1 line, 1 line of output)
pasted on Jul 17:
1
print("Hello World")
view (1 line, 1 line of output)


OCaml:
pasted on Jun 18:
1
print_string "Hello world!\n"
view (1 line, 1 line of output)
pasted on Jun 6:
1
print_endline "hello world!";;
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
2
3
4
5
6
<?php
function krutiToUnicode(){
echo "Hello world!";
}
krutiToUnicode();
?>
view (6 lines, 1 line of output)
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)


Perl:
pasted on Jun 14:
1
print ("Hello World")
view (1 line, 1 line of output)
pasted on May 24:
1
print "Hello, world\n";
view (1 line, 1 line of output)


Python:
pasted 5 hours ago:
1
print("hello world")
view (1 line, 1 line of output)
pasted yesterday:
1
2
a = "Hello, World"
print(a.upper())
view (2 lines, 1 line of output)


Ruby:
pasted on Jul 17:
1
puts "hello world"
view (1 line, 1 line of output)
pasted on Jul 15:
1
puts "Hello World!"
view (1 line, 1 line of output)


Scheme:
pasted on Jul 11:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on Jul 6:
1
(display "Hello, World!")
view (1 line, 1 line of output)