[ 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 39 minutes ago:
1
2
3
4
5
6
7
8
9
#include<stdio.h>
int main()
{
char *s = "Hello world";
printf(s);


return 0;
}
view (9 lines, 1 line of output)
pasted 39 minutes ago:
1
2
3
4
5
6
7
8
9
#include<stdio.h>
int main()
{
char *s = "Hello world";
printf(s);

int x = 10;
return 0;
}
view (9 lines, 1 line of output)


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

int main()
{
  std::cout << "Hello world!\n";
}
view (6 lines, 1 line of output)
pasted 5 hours ago:
1
2
3
4
5
6
7
8
#include <iostream>
using namespace std;

int main()
{
  cout << "Hello World!" << endl;
  return 0;
}
view (8 lines, 1 line of output)


D:
pasted 8 hours ago:
1
2
3
4
5
6
7
8
// Hello World in D

import std.stdio;

void main()
{
   writefln("Hello World!");
}
view (9 lines, 1 line of output)
pasted on Mar 14:
1
2
3
4
5
6
7
	import std.stdio;
	 
	int main(char[][] args)
	{
	    writef("Hello world!");
	    return 0;
	}
view (7 lines, 1 line of output)


Haskell:
pasted 12 hours ago:
1
2
3
4
module Main where
 
main :: IO ()
main = putStrLn "Hello World!"
view (4 lines, 1 line of output)
pasted yesterday:
1
2
3
4
module Main where
 
main :: IO ()
main = putStrLn "Hello World!"
view (4 lines, 1 line of output)


Lua:
pasted 8 hours ago:
1
print "Hello World!\n";
view (1 line, 2 lines of output)
pasted 8 hours ago:
1
print "Hello world"
view (1 line, 1 line of output)


OCaml:
pasted on Feb 28:
1
print_string "Hello World!\n";;
view (1 line, 1 line of output)
pasted on Feb 8:
1
print_endline "Hello World";;
view (1 line, 1 line of output)


PHP:
pasted yesterday:
1
2
3
<?php
echo "Hello world!";
?>
view (3 lines, 1 line of output)
pasted yesterday:
1
2
3
<?php
  echo "hello world";
?>
view (3 lines, 1 line of output)


Perl:
pasted 4 hours ago:
1
2
  #!/usr/bin/perl
    print "Hello, world!\n";
view (2 lines, 1 line of output)
pasted 7 hours ago:
1
print 'hello, world';
view (1 line, 1 line of output)


Python:
pasted 3 hours ago:
1
print("hello world");
view (1 line, 1 line of output)
pasted 3 hours ago:
1
print("hello world")
view (1 line, 1 line of output)


Ruby:
pasted on Mar 13:
1
puts "Hello World"
view (1 line, 1 line of output)
pasted on Mar 12:
1
2
3
4
5
def helloworld
  puts 'Hello world'
end

helloworld
view (5 lines, 1 line of output)


Scheme:
pasted 14 hours ago:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted yesterday:
1
(display "Hello, World!")
view (1 line, 1 line of output)


Tcl:
pasted on Mar 8:
1
puts -nonewline "Hello, world!"
view (1 line, 1 line of output)
pasted on Mar 4:
1
puts -nonewline "Hello, world!"
view (1 line, 1 line of output)