[ create a new paste ] login | about

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

C:
pasted yesterday:
1
2
3
4
5
6
#include <stdio.h>

int main(void) {
    printf("hello world");
    return 0;
}
view (6 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
8
#include <stdio.h>

int main()
{
    printf("Hello, world!\n");

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


C++:
pasted 8 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 8 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)


Haskell:
pasted on Aug 15:
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 Oct 14:
1
print ("hello world!")
view (1 line, 1 line of output)
pasted on Sep 28:
1
2
print ("hello world")
 
view (2 lines, 1 line of output)


PHP:
pasted on Oct 13:
1
2
3
4
5
6
7
<?php
$str = "<h1>Hello World</h1>";

$newstr = filter_var($str, FILTER_SANITIZE_STRING);
echo $newstr;

echo $data;
view (7 lines, 1 line of output)
pasted on Oct 13:
1
2
3
4
5
<?php
$str = "<h1>Hello World</h1>";

$newstr = filter_var($str, FILTER_SANITIZE_STRING);
echo $newstr;
view (5 lines, 1 line of output)


Perl:
pasted yesterday:
1
print STDERR "Hello World\n";
view (1 line, 1 line of output, 13 comments)
pasted on Aug 15:
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
2
3
4
5
def main ():

    print ("Hello world!")

main()
view (5 lines, 1 line of output)


Ruby:
pasted on Oct 7:
1
puts "hello world"
view (1 line, 1 line of output)
pasted on Sep 30:
1
print "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)