This article introduces us with how to write the first computer program of “Hello World”, across various languages. Along with the programs, the comments are provided for a better understanding of the terminologies and keywords used in the program
Learning any programming can be simplified into:
- Writing the program in a text-editor and saving it with correct extension(.CPP, .C, .CSHARP, .JAVA, etc)
- Compiling the program using a compiler or online IDE
- Understanding the basic terminologies.
The “Hello World” program is the first step towards learning any programming language and also one of the simplest programs you will learn. All you have to do is display the message “Hello World” on the screen. Let us now look at the program in most of the language:
Here are the links to all the individual “Hello World” programs in different languages:
1. Hello World in C
C
#include <stdio.h>
int main()
{
printf ( "Hello World" );
return 0;
}
|
2. Hello World in C++
C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" ;
return 0;
}
|
3. Hello World in C#
C#
using System;
namespace HelloWorldApp {
class Geeks {
static void Main( string [] args)
{
Console.WriteLine( "Hello World" );
Console.ReadKey();
}
}
}
|
4. Hello World in Java
Java
class HelloWorld {
public static void main(
String args[])
{
System.out.println( "Hello World" );
}
}
|
5. Hello World in Python
6. Hello World in Perl
Perl
#!/usr/bin/perl
use strict;
use warnings;
print ( "Hello World\n" );
|
7. Hello World in Scala
Scala
object Geeks
{
def main(args : Array[String])
{
println( "Hello World" )
}
}
|
8. Hello World in Go
Go
package main
import "fmt"
func
main()
{
fmt.Println( "!... Hello World ...!" )
}
|
9. Hello World in PHP
PHP
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World" ;
?>
</body>
</html>
|
10. Hello World in HTML
HTML
< html >
< header >< title ></ title ></ header >
< body >
Hello World
</ body >
</ html >
|
11. Hello World in JavaScript
JavaScript
<script>
console.log( 'Hello World' );
</script>
|
12. Hello World in Julia
Julia
/ / Julia program
println( "Hello World" )
|
13. Hello World in R
14. Hello world in Ruby
15. Hello World in Solidity
Solidity
pragma solidity ^0.5.0;
contract helloGeeks {
function renderHelloGeeks () public pure returns (string) {
return 'Hello World' ;
}
}
|
16. Hello World in XML
XML
<? xml version = "1.0" encoding = "UTF-8" ?>
< text >
< para >Hello World</ para >
</ text >
|
17. Hello World in Objective-C
ObjectiveC
#import
#import
int main( void )
{
NSLog (@"Hello World
");
return 0;
}
|
18. Hello World in Kotlin
Kotlin
fun main(args: Array<String>) {
println( "Hello World" )
}
|
19. Hello World in Dart
Dart
void main() {
print( 'Hello World' );
}
|
20. Hello World in MATLAB
Matlab
fprintf( 'Hello World!' );
disp( 'Hello World!' );
|
Below are the codes of all the languages:
C
#include <stdio.h>
int main()
{
printf ( "Hello World" );
return 0;
}
|
C++
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" ;
return 0;
}
|
C#
using System;
namespace HelloWorldApp {
class Geeks {
static void Main( string [] args)
{
Console.WriteLine( "Hello World" );
Console.ReadKey();
}
}
}
|
Java
class HelloWorld {
public static void main(
String args[])
{
System.out.println( "Hello World" );
}
}
|
Python
Perl
#!/usr/bin/perl
use strict;
use warnings;
print ( "Hello World\n" );
|
Scala
object Geeks
{
def main(args : Array[String])
{
println( "Hello World" )
}
}
|
HTML
< html >
< header >< title ></ title ></ header >
< body >
Hello World
</ body >
</ html >
|
PHP
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World" ;
?>
</body>
</html>
|
Julia
Ruby
R
Go
package main
import "fmt"
func main() {
fmt.Println( "Hello World" )
}
|
Javascript
<script>
console.log( 'Hello World' );
</script>
|
Solidity
pragma solidity ^0.5.0;
contract helloGeeks {
function renderHelloGeeks () public pure returns (string) {
return 'Hello World' ;
}
}
|
XML
<? xml version = "1.0" encoding = "UTF-8" ?>
< text >
< para >Hello World</ para >
</ text >
|
ObjectiveC
#import
#import
int main( void )
{
NSLog (@"Hello World
");
return 0;
}
|
Kotlin
fun main(args: Array<String>) {
println( "Hello World" )
}
|
Dart
void main() {
print( 'Hello World' );
}
|
Matlab
fprintf( 'Hello World!' );
disp( 'Hello World!' );
|
Output:
Hello World