[ 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 yesterday:
1
2
3
4
5
6
7
#include <stdio.h>
int x;
int main()
{
printf("Hello world \n");
return 0;
}
view (7 lines, 1 line of output)
pasted yesterday:
1
2
3
4
5
6
7
#include <stdio.h> // Standard C function Library such as printf
int x;             // Declaring the variable x as an integer
int main()        // Entry Point to start the main function
{
printf("Hello world \n");    // This is similar to MATLAB's fprintf
return 0;                    // Outputs a 0, mostly good practive to end
}
view (7 lines, 1 line of output)


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

using namespace std;

int main(){
cout<<"Hello World";
}
view (7 lines, 1 line of output)
pasted 7 hours ago:
1
2
3
int main() {
    std::cout<<"hello world!" << std::endl;
}
view (3 lines, 1 line of output)


Haskell:
pasted on Nov 18:
1
2
main = putStrLn "Hello, world!"
main2 = putStrLn "Hi wo!"
view (2 lines, 1 line of output)
pasted on Nov 18:
1
main = putStrLn "Hello, world!"
view (1 line, 1 line of output)


Lua:
pasted on Nov 8:
1
print("Hello, world!")
view (1 line, 1 line of output)
pasted on Nov 8:
1
print("Hello, world!")
view (1 line, 1 line of output)


OCaml:
pasted on Sep 11:
1
print_endline "Hello, World!"
view (1 line, 1 line of output)
pasted on Aug 18:
1
print_string "Hello, world"
view (1 line, 1 line of output)


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


Perl:
pasted on Nov 14:
1
2
3
#!/usr/bin/perl

print("hello world");
view (3 lines, 1 line of output)
pasted on Nov 14:
1
2
3
#!/usr/bin/perl

print("hello world");
view (3 lines, 1 line of output)


Python:
pasted yesterday:
1
2
x = 1
print('Hello world!')
view (2 lines, 1 line of output)
pasted on Nov 20:
1
2
greeting = 'Hello World'
print( greeting )
view (2 lines, 1 line of output)


Ruby:
pasted on Nov 12:
1
print("Hello World")
view (1 line, 1 line of output)
pasted on Nov 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module GreetingEn
  def welcome()
    return 'Hello world!'
  end
end

module GreetingKo
  def welcome()
    return 'μ•ˆλ…• 세계'
  end
end

include GreetingKo
include GreetingEn
puts GreetingKo.welcome()
view (15 lines, 1 line of output)


Scheme:
pasted on Nov 5:
1
(display "Hello, World!")
view (1 line, 1 line of output)
pasted on Oct 11:
1
2
3
(begin
  (display "Hello, World!")
  (newline))
view (3 lines, 1 line of output)