[ create a new paste ] login | about

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

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


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

using namespace std;

int main(){

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


D:
pasted on Sep 25:
1
2
3
4
5
6
import std.stdio;

void main()
{
    printf("Hello, World!");
}
view (6 lines, 1 line of output)
pasted on Sep 6:
1
2
3
4
int main(){
printf("Hello World!");
return 0;
}
view (4 lines, 1 line of output)


Haskell:
pasted on Sep 27:
1
main = putStrLn "hello world"
view (1 line, 1 line of output)
pasted on Sep 27:
1
main = putStrLn "hello world"
view (1 line, 1 line of output)


Lua:
pasted 4 hours ago:
1
print("Hello world!")
view (1 line, 1 line of output)
pasted on Sep 28:
1
print("Hello, world!")
view (1 line, 1 line of output)


OCaml:
pasted on Aug 4:
1
print_string "hello world!\n";;
view (1 line, 1 line of output)
TT22 - pasted on Jun 4:
1
2
3
let hello = "Hello" ;;
let world = "world" ;;
Printf.printf "%s %s!" hello world ;;
view (3 lines, 1 line of output)


PHP:
pasted yesterday:
1
2
3
4
<?php
$str = "Hello World";
echo str_pad($str,-1,"_",STR_PAD_LEFT);
?>
view (4 lines, 1 line of output)
pasted yesterday:
1
2
3
4
<?php
$str = "Hello World";
echo str_pad($str,0,"_",STR_PAD_LEFT);
?>
view (4 lines, 1 line of output)


Perl:
pasted 9 hours ago:
1
2
$str = "\Uhello, world!";
print "$str";
view (2 lines, 1 line of output)
pasted 10 hours ago:
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl

# Function definition
sub Hello{
   print "Hello, World!\n";
}

# Function call
Hello();
view (9 lines, 1 line of output)


Python:
pasted 1 hour ago:
1
print('Hello, world')
view (1 line, 1 line of output)
pasted 5 hours ago:
1
2
#!/usr/bin/python
print "Hello, World!"
view (2 lines, 1 line of output)


Ruby:
pasted 5 hours ago:
1
print "Hello, World!\n"
view (1 line, 1 line of output)
pasted 17 hours ago:
1
2
3
4
5
6
7
8
9
class A 
    attr_accessor :a
    def initialize(a) 
        @a = a
    end
end

aa = A.new("hello, world!")
puts aa.a
view (9 lines, 1 line of output)


Scheme:
pasted on Sep 9:
1
2
(display "Hello, World!")
 (newline)
view (2 lines, 1 line of output)
pasted on Sep 8:
1
2
(begin
  (display "Hello, world!"))
view (2 lines, 1 line of output)


Tcl:
pasted on May 5:
1
2
set hello "Hello, World!"
puts -nonewline $hello ;
view (2 lines, 1 line of output)