Simple "Hello World" in 10 Popular Languages
When starting to learn a new programming language quite often the first program that one learns is a simple program which prints "Hello World" to the screen. The following is a small collection of these programs in 10 popular programming languages:
PHP
<?php
// Hello World in PHP
echo 'Hello World!';
?>
C#
// Hello World in Microsoft C# ("C-Sharp").
using System;
class HelloWorld
{
public static int Main(String[] args)
{
Console.WriteLine("Hello, World!");
return 0;
}
}
JavaScript
<html>
<body>
<script language="JavaScript" type="text/javascript">
// Hello World in JavaScript
document.write('Hello World');
</script>
</body>
</html>
Perl
# Hello world in perl
print "Hello World!\n";
C-Windows
/* Hello world in C for MS-Windows */
#include <windows.h>
int PASCAL WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, LPSTR CmdLine, int Show)
{
MessageBox(GetActiveWindow(), "Hello World!", "Hello Windows World", MB_OK);
return 0;
}
C++-ISO
// Hello World in ISO C++
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
}
Ruby
# Hello World in Ruby
puts "Hello World!"
Java
// Hello World in Java
import java.io.*;
class HelloWorld {
static public void main( String args[] ) {
System.out.println( "Hello World!" );
}
}
Python
# Hello World in Python
print "Hello World"
VisualBasic.NET
'Hello World in Visual Basic .NET (VB.NET)
Imports System.Console
Class HelloWorld
Public Shared Sub Main()
WriteLine("Hello, world!")
End Sub
End Class
1 comment:
A definitive collection of Hello World programs and be found at the following link:
http://www.roesler-ac.de/wolfram/hello.htm
Post a Comment