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

int main()
{
    printf("Hello world!\n");
    return 0;
}
view (8 lines, 1 line of output)


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

using namespace std;

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


D:
pasted on Oct 17:
1
2
3
4
int main() {
    printf("Hello World");
    return 0;
}
view (4 lines, 1 line of output)
pasted on Oct 12:
1
2
3
4
int main() {
    printf("Hello World");
    return 0;
}
view (4 lines, 1 line of output)


Haskell:
pasted on Oct 29:
1
2
3
4
module Main where

main :: IO ()
main = putStrLn "Hello World"
view (4 lines, 1 line of output)
pasted on Oct 27:
1
2
3
4
module Main where

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


Lua:
pasted 25 minutes 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)


OCaml:
pasted on Oct 27:
1
print_string "Hello World!"
view (1 line, 1 line of output)
pasted on Oct 27:
1
print_endline "Hello World!"
view (2 lines, 1 line of output)


PHP:
pasted yesterday:
1
2
3
4
5
<?php

    echo "Hello, world!";

?>
view (5 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
<?

echo 'hello world';

?>
view (5 lines, 1 line of output)


Perl:
pasted yesterday:
1
print "hello world\n";
view (1 line, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl

print "Hello World!\n";

$str = " #define vamsi varanasi 1";

$define_string = qr/^\s*#define\s+(\w+)\s*$/;

$define_value_string = qr/^\s*#define\s+(\w+)\s+(\w+)\s*$/;

if($str =~ m/$define_string/){
  print "YO YO \n";
}

if($str =~ m/$define_value_string/){
  print "YES \n";
}
view (17 lines, 1 line of output)


Python:
pasted 3 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 yesterday:
1
puts "hello world"
view (1 line, 1 line of output)
pasted on Oct 30:
1
puts "Hello World"
view (1 line, 1 line of output)


Scheme:
Abdus-Salam - pasted on Oct 30:
1
(display "Hello World!")
view (1 line, 1 line of output)
pasted on Oct 26:
1
(display "Hello, world!")
view (1 line, 1 line of output)


Tcl:
pasted yesterday:
1
puts -nonewline "Hello world!"
view (2 lines, 1 line of output)
pasted on Oct 6:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)