[ 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
6
7
8
9
10
#include <stdio.h>
 
int main (void)

{
float a;
    puts ("Hello, World!");
scanf ("%f",&a);
    return 0;
}
view (10 lines, 1 line of output)
pasted 2 hours ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
 
int main (void)

{
float a;
    puts ("Hello, World!");
scanf ("%f",&a);
    return 0;
}
view (10 lines, 1 line of output)


C++:
pasted 53 minutes ago:
1
2
3
4
5
 int main ()
 {
 cout << "Hello World!";
 return 0;
    }
view (5 lines, 1 line of output)
pasted 54 minutes ago:
1
2
3
4
5
 int main ()
 {
 cout << "Hello World!";
 return 0;
 } 
view (6 lines, 1 line of output)


D:
pasted on Aug 27:
1
2
3
4
5
6
7
8
9
10
11
// Shawn Pixley
// N-2
// 8/27/2014

import std.stdio;
 
void main()
{
  writefln("Hello, world!");
  //writefln(clock.currTime());
}
view (11 lines, 1 line of output)
pasted on Aug 27:
1
2
3
4
5
6
import std.stdio;

void main()
{
    writefln("Hello world!");
}
view (6 lines, 1 line of output)


Haskell:
pasted 13 hours ago:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)
pasted yesterday:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)


Lua:
pasted 13 hours ago:
1
print "hello world"
view (1 line, 1 line of output)
pasted on Aug 30:
1
2
3
4
5
var = 42

if var then
print "hello world"
end
view (5 lines, 1 line of output)


OCaml:
pasted on Aug 8:
1
2
let x = "hello world";;
Printf.printf "%s" x;;
view (2 lines, 1 line of output)
pasted on Aug 8:
1
2
let x = "hello world";;
Printf.printf "%s" x;;
view (2 lines, 1 line of output)


PHP:
pasted 6 hours ago:
1
2
3
<?php
print 'Hello World'
?>
view (3 lines, 1 line of output)
pasted 7 hours ago:
1
2
3
<?php
print"hello world";
?>
view (3 lines, 1 line of output)


Perl:
pasted yesterday:
1
2
3
4
$abc="hello world";
@abc=('$abc',"dataabc");

print eval @abc[0];
view (4 lines, 1 line of output)
pasted yesterday:
1
2
3
4
$abc="hello world";
@abc=($abc,"dataabc");

print @abc[0];
view (4 lines, 1 line of output)


Python:
pasted 4 minutes ago:
1
print "Hello, World!" 
view (1 line, 1 line of output)
pasted 53 minutes ago:
1
2
#!/usr/bin/env python
print "Hello, World!"
view (2 lines, 1 line of output)


Ruby:
pasted yesterday:
1
print "Hello World"
view (1 line, 1 line of output)
pasted on Aug 27:
1
2
3
4
5
6
# Jeff Schafer
# Programming Languages
# 8/27/14
# N-02
# p001hello.rb
puts 'Hello World'
view (6 lines, 1 line of output)


Scheme:
pasted on Aug 22:
1
(display "Hello, world!")
view (1 line, 1 line of output)
pasted on Aug 19:
1
(display "Hello, World!")
view (1 line, 1 line of output)


Tcl:
pasted on Jul 31:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)
pasted on Jul 16:
1
puts -nonewline "Hello world!"
view (1 line, 1 line of output)