[ create a new paste ] login | about

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

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


C++:
pasted 9 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)
pasted 9 hours ago:
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
 
	std::cout << "hello world" ;
 
	return 0;
}
view (10 lines, 1 line of output)


Haskell:
pasted yesterday:
1
2
3
4
5
6
main = putStrLn "Hello, World!"


fac n
  | n <= 1    = 1
  | otherwise = fac (n-1) * n
view (6 lines, 1 line of output)
pasted yesterday:
1
main = putStrLn "Hello, World!"
view (1 line, 1 line of output)


Lua:
pasted on May 22:
1
print ("Hello World")
view (1 line, 1 line of output)
pasted on May 17:
1
print("hello world")
view (1 line, 1 line of output)


PHP:
pasted 15 hours ago:
1
2
3
4
<?php
$test = "Hello World!";
echo $test;
?>
view (4 lines, 1 line of output)
pasted 16 hours ago:
1
2
3
4
5
6
<?php
$test = "Hello World!";
$test2 = 2;
$test2 = $test2 + 3;
?>
<?php echo $test ?>
view (6 lines, 1 line of output)


Perl:
pasted on May 22:
1
2
3
#!/usr/bin/perl

print "Hello, World\n";
view (3 lines, 1 line of output)
pasted on May 22:
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl

print "Hello, World\n";

__END__

=head1 Hello, World Example
This example demonstrate very basic syntax of Perl.
print "Hello, Universe\n"
view (9 lines, 1 line of output)


Python:
pasted 8 hours ago:
1
print("hello world")
view (1 line, 1 line of output)
pasted 14 hours ago:
1
2
3
a=1
b=5
print 'hello world'
view (4 lines, 1 line of output)


Ruby:
pasted 16 hours ago:
1
puts "hello world!"
view (1 line, 1 line of output)
pasted on May 21:
1
puts 'hello world'
view (1 line, 1 line of output)


Scheme:
pasted on May 17:
1
(display "Hello, World")
view (1 line, 1 line of output)
pasted on May 3:
1
2
3
4
(display "Hello, World!")
(+ 1 2)
(+ 534 689)
(* 4 6)
view (4 lines, 1 line of output)