[ 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 6 hours ago:
1
2
3
4
5
#include "stdio.h"
void main()
{
printf("Hello world!");
}
view (5 lines, 1 line of output)
pasted 7 hours ago:
1
2
3
4
5
6
7
8
9
#include <stdio.h>

int main()
{
   /* 我的第一个 C 程序 */
   printf("Hello, World! \n");
   
   return 0;
}
view (9 lines, 1 line of output)


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

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

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


Haskell:
pasted on Sep 4:
1
main = putStrLn "hello world"
view (1 line, 1 line of output)
pasted on Aug 15:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)


Lua:
pasted on Sep 13:
1
print("Hello, world!")
view (1 line, 1 line of output)
pasted on Aug 26:
1
print("Hello World")
view (1 line, 1 line of output)


OCaml:
pasted on Sep 11:
1
print_endline "Hello, World!"
view (1 line, 1 line of output)
pasted on Aug 18:
1
print_string "Hello, world"
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
2
3
<?php
 echo 'Hello World';
?>
view (3 lines, 1 line of output)
pasted on Sep 11:
1
2
3
<?php
 echo "Hello World";
?>
view (3 lines, 1 line of output)


Perl:
pasted on Sep 6:
1
print "Hello world";
view (1 line, 1 line of output)
pasted on Sep 6:
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 Sep 9:
1
puts "Hello world!"
view (1 line, 1 line of output)
pasted on Aug 21:
1
print "Hello World"
view (1 line, 1 line of output)


Scheme:
pasted on Sep 4:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on Aug 26:
1
2
3
4
5
;The first program

(begin
  (display "Hello, World!")
  (newline))
view (5 lines, 1 line of output)