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

int main (void) {

	printf("Hello World");
	return 0;

}
 
view (9 lines, 1 line of output)
pasted 7 hours ago:
1
2
3
4
5
6
7
8
#include <stdio.h>

int main()
{
    printf("Hello World");

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


C++:
pasted 1 hour ago:
1
2
3
4
5
6
7
8
9
10
11
12
using namespace std;

int main()
{
    int x = 2;
    switch(x){
        case 1:cout<<"One";
        case 0:cout<<"Zero";
        case 2:cout<<"Hello World";
    }
    return 0;
}
view (12 lines, 1 line of output)
pasted 1 hour ago:
1
2
3
4
5
6
7
8
9
10
11
#include <iostream>
#include <string>

using namespace std;

int main(){

cout << "Hello World" << endl;

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


Haskell:
pasted on Jul 24:
1
main = putStrLn "Hello World!"
view (1 line, 1 line of output)
pasted on Jul 8:
1
2
3
4
module Main where

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


Lua:
pasted on Jul 21:
1
2
3
currentInfo = "hello world"
currentInfo = string.gsub(currentInfo,'"',"") -- remove any quotes
print (currentInfo)
view (3 lines, 1 line of output)
pasted on Jul 19:
1
print("Hello, world!")
view (1 line, 1 line of output)


OCaml:
pasted on Mar 28:
1
print_string "Hello world!\n"
view (1 line, 1 line of output)
pasted on Mar 28:
1
print_string "Hello world!\n";
view (1 line, 1 line of output)


PHP:
pasted on Jul 27:
1
2
3
<?php
echo "hello world";
?>
view (3 lines, 1 line of output)
pasted on Jul 22:
1
2
3
4
5
6
<?php

echo "Hello World";


php?>
view (6 lines, 1 line of output)


Perl:
pasted on Jun 24:
1
2
3
4
5
6
7
8
9
10
#!/usr/bin/perl
#
# The traditional first program.
 
# Strict and warnings are recommended.
use strict;
use warnings;
 
# Print a message.
print "Hello, World!\n";
view (10 lines, 1 line of output)
pasted on Jun 12:
1
print "Hello, World!\n";
view (1 line, 1 line of output)


Python:
pasted 7 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)


Ruby:
pasted on Jul 31:
1
print 'Hello world'
view (1 line, 1 line of output)
pasted on Jul 31:
1
puts 'Hello world'
view (1 line, 1 line of output)


Scheme:
pasted on Jul 27:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on Apr 14:
1
(display "Hello, World")
view (1 line, 1 line of output)