First article! Definitely must be a “Hello World” examples article. A “Hello World” program is a computer program which prints out “Hello, world!” on a display device. It is used in many introductory tutorials for teaching a programming language.
It is often considered to be tradition among programmers for people attempting to learn a new programming language to write a “Hello World!” program as one of the first steps of learning that particular language. Such a program is typically one of the simplest programs possible in most computer languages.
C example:
1 2 3 4 5 6 |
#include int main(void) { printf("Hello, World!\n"); return 0; } |
C++ example:
1 2 3 4 5 6 7 |
#include using namespace std; int main() { cout<< "Hello, world!\n"; return 0; } |
C# example:
1 2 3 4 5 6 7 8 |
class HelloWorldApp { static void Main() { System.Console.WriteLine("Hello, world!"); } } |
JavaScript example:
1 2 |
document.write('Hello, world!'); alert('Hello, world!'); |
Perl example:
1 |
print "Hello, world!\n"; |
PHP example:
1 |
<? print "Hello, world!";?> |
Pascal example:
1 2 3 4 5 |
program hello; begin writeln('Hello, world!'); readln; end. |
SQL example:
1 2 3 4 |
CREATE TABLE message (text char(15)); INSERT INTO message (text) VALUES ('Hello, world!'); SELECT text FROM message; DROP TABLE message; |
Bash or sh example:
1 2 3 4 |
echo 'Hello, world!' printf 'Hello, world!\n' printf '%s' #Hello, world!\n' |
Hello world!