[ 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 3 hours ago:
1
2
3
4
5
6
#include <stdio.h>
int main() {
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;
}
view (6 lines, 1 line of output)
pasted 3 hours ago:
1
2
3
4
5
#include <stdio.h>
int main() {
   printf("Hello, World!");
   return 0;
}
view (5 lines, 1 line of output)


C++:
pasted 2 hours ago:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void fun1(...);

int main(){


cout<<"Hello World\n" <<endl;

return 0;
}
void func1(...)
{

cout<<"hello func";
}
view (14 lines, 2 lines of output)
pasted 2 hours ago:
1
2
3
4
5
6
7
8
9
void fun1(...);

int main(){


cout<<"Hello World\n" <<endl;

return 0;
}
view (9 lines, 2 lines of output)


Haskell:
pasted on Mar 15:
1
main = putStrLn "Hello World"
view (1 line, 1 line of output)
pasted on Mar 15:
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 Mar 28:
1
2
3
4
5
function test() 
    print("Hello World!")
end

test()
view (5 lines, 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 Apr 4:
1
2
3
<?php
echo 'hello world!'
?>
view (3 lines, 1 line of output)
pasted on Apr 3:
1
2
3
<?
echo "Hello World";
?>
view (3 lines, 1 line of output)


Perl:
pasted 15 hours ago:
1
2
3
4
5
print "Hello World!\n";

my $j_leg_sort = '--';
our $v_leg_sort   = qr/^[\W|\w]{1,2}$/;             # Valid Leg Sort
print 'Invalid leg sort'   if $j_leg_sort && ($j_leg_sort !~ $v_leg_sort);
view (5 lines, 1 line of output)
pasted on Mar 30:
1
2
3
4
5
print "Hello World!\n";

my $j_leg_sort = '--';
our $v_leg_sort   = qr/^[\W|\w]{1,2}$/;             # Valid Leg Sort
print 'Invalid leg sort'   if $j_leg_sort && ($j_leg_sort !~ $v_leg_sort);
view (5 lines, 1 line of output)


Python:
pasted 12 hours ago:
1
print("Hello world")
view (1 line, 1 line of output)
pasted 12 hours ago:
1
print("Hello world")
view (1 line, 1 line of output)


Ruby:
pasted on Apr 1:
1
puts "Hello World"
view (1 line, 1 line of output)
pasted on Mar 20:
1
puts "Hello, world!"
view (1 line, 1 line of output)


Scheme:
pasted 16 hours ago:
1
(display "Hello World!")
view (1 line, 1 line of output)
intellab - pasted on Mar 16:
1
(display "Hello World")
view (1 line, 1 line of output)