Hello World: Difference between revisions
From charlesreid1
(→C++) |
(→Bash) |
||
| Line 1: | Line 1: | ||
= Bash = | = Bash = | ||
A simple hello world example using [[Bash]]. | |||
HelloWorld.sh: | HelloWorld.sh: | ||
| Line 13: | Line 15: | ||
$ ./HelloWorld.sh | $ ./HelloWorld.sh | ||
</syntaxhighlight> | </syntaxhighlight> | ||
= C++ = | = C++ = | ||
Revision as of 08:01, 5 October 2010
Bash
A simple hello world example using Bash.
HelloWorld.sh:
#!bin/sh
echo "Hello world!"
To run it:
$ chmod +x HelloWorld.sh
$ ./HelloWorld.sh
C++
A simple hello world example in C++.
HelloWorld.cc:
#include <iostream>
int main()
{
std::cout << "Hello, world! This is C++.\n";
}
To run it:
$ g++ HelloWorld.cc -o hello.x
$ ./hello.x
PHP
HelloWorld.php
<html>
<body>
<?php
echo "Hello world!";
?>
</body>
</html>
To run HelloWorld.php:
$ php HelloWorld.php
Alternatively, if you are running a local apache server and have PHP enabled, you can put HelloWorld.php into your web documents directory, and then point you web browser to http://localhost/HelloWorld.php.
Python
HelloWorld.py:
print "Hello, World!"
To run it:
$ python HelloWorld.py
Alternatively:
$ python -c "print 'Hello World! \n'"