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

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


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

using namespace std;

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

int main()
{
    printf("Hello World!");
}
view (6 lines, 1 line of output)


Haskell:
pasted on May 5:
1
main = putStrLn "Hello World!"
view (1 line, 1 line of output)
pasted on Mar 22:
1
main = putStrLn "hello World!"
view (1 line, 1 line of output)


Lua:
pasted yesterday:
1
print("Hello, world!")
view (1 line, 1 line of output)
pasted on May 17:
1
print("Hello, world!")
view (1 line, 1 line of output)


OCaml:
pasted on Apr 6:
1
print_string "Hello World"
view (1 line, 1 line of output)


PHP:
pasted 2 hours ago:
1
2
3
4
<?php

echo "Hello world!\n";
?>
view (4 lines, 1 line of output)
pasted on May 19:
1
2
3
<?php
echo("hello world");
?>
view (3 lines, 1 line of output)


Perl:
pasted yesterday:
1
print("Hello, world!")
view (1 line, 1 line of output)
pasted on May 5:
1
2
3
4
use strict;     #強迫使用者以嚴謹的方式編寫
use warnings;   #開啟警告功能

print "Hello, world";
view (5 lines, 1 line of output)


Python:
pasted 1 hour ago:
1
2
#This is a comment!!!
print("Hello, World!")
view (2 lines, 1 line of output)
pasted 1 hour ago:
1
print("Hello, World!")
view (1 line, 1 line of output)


Ruby:
pasted on May 19:
1
puts "hello world"
view (1 line, 1 line of output)
pasted on May 18:
1
puts "Hello World!"
view (1 line, 1 line of output)


Scheme:
pasted on Mar 1:
1
(display "Hello World")
view (1 line, 1 line of output, 2 comments)
pasted on Feb 21:
1
2
(display "hello, world")
(newline)
view (2 lines, 1 line of output)