[ 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 2 hours ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
int main ()
{
int x;
printf ("Hello World\n");
return (0);

for (x = 0; x < 5;  ++x)
printf ("%i\n",x);
 }
view (10 lines, 1 line of output)
pasted 3 hours ago:
1
2
3
4
5
6
7
8
9
10
#include <stdio.h>
int main ()
{
int x;
printf ("Hello World\n");
return (0);

for (x = 0; x < 5;  ++x)
printf ("%i\n",x);
 }
view (10 lines, 1 line of output)


C++:
pasted 40 minutes ago:
#include <iostream>

class q
{
private:
    float x;
    float y;
    float z;
    float w;

public:
    q() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
    q(float x_, float y_, float z_, float w_) : x(x_), y(y_), z(z_), w(w_) {}

    q conj()
    {
        return q(-x, -y, -z, w);
    }

    q operator*(q& r)
    {
        return q(
            x * r.w + w * r.x - z * r.y + y * r.z,
            y * r.w + z * r.x + w * r.y - x * r.z,
            z * r.w - y * r.x + x * r.y + w * r.z,
            w * r.w - x * r.x - y * r.y - z * r.z
        );
    }
};

int main()
{
   std::printf("hello world");

    return 0;
}
view (36 lines, 1 line of output)
pasted 44 minutes ago:
#include <iostream>

class q
{
private:
    float x;
    float y;
    float z;
    float w;

public:
    q() : x(0.0f), y(0.0f), z(0.0f), w(0.0f) {}
    q(float x_, float y_, float z_, float w_) : x(x_), y(y_), z(z_), w(w_) {}

    q conj()
    {
        return q(-x, -y, -z, w);
    }
};

int main()
{
   std::printf("hello world");

    return 0;
}
view (26 lines, 1 line of output)


Haskell:
pasted on Jan 2:
1
2
3
4
5
6
{-# LANGUAGE RankNTypes #-}

dneg :: (forall r. (a -> r) -> r) -> a
dneg f = f id

main = putStrLn $ dneg (\f -> f "Hello World!")
view (6 lines, 1 line of output)
pasted on Nov 26:
1
2
3
4
module Main where

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


Lua:
pasted on Dec 27:
1
print("hello world")
view (1 line, 1 line of output)
pasted on Dec 11:
1
print("Hello, world!")
view (1 line, 1 line of output)


OCaml:
pasted on Nov 14:
1
print_endline "hello, world!"
view (1 line, 1 line of output)


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


Perl:
pasted on Jan 17:
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl

print "Hello, World\n";

while(<DATA>){
  print $_;
}

__END__
view (9 lines, 1 line of output)
pasted on Dec 31:
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 4 hours ago:
1
print("hello world")
view (1 line, 1 line of output)


Ruby:
pasted on Jan 20:
1
puts "Hello world"
view (1 line, 1 line of output)
pasted on Jan 16:
1
puts "Hello World!"
view (1 line, 1 line of output)


Scheme:
pasted on Jan 20:
1
( display "hello world" )
view (1 line, 1 line of output)
pasted on Oct 5:
1
(display "Hello, World!")
view (1 line, 1 line of output, 1 comment)