In this article, I’ll show you how to create your first Hello World computer program in various languages. Along with the program, comments are provided to help you better understand the terms and keywords used in the
Learning program. Programming can be simplified as follows:
- Write the program in a text editor and save it with the correct extension (.CPP, .C, CSHARP, .JAVA, .PY, etc.).
- Compiling Programs Using Compilers or Online IDEs.
- Understand basic terminology.
The Hello World program is the first step in learning a programming language and one of the easiest programs to learn. It just prints a “Hello World” message to the screen. Now let’s look at the programs in most languages:
Here are links to all the individual “Hello World” programs in various 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
Python
print ( "Hello World" )
print (
)
|
Output
Hello World
Hello
world
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
C
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>
|
Output
<!DOCTYPE html>
<html>
<body>
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.8.16;
contract HelloGeeks{
function renderHelloGeeks () public pure returns (string memory) {
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!' );
|
Rust
fn main() {
println!( "Hello, world!" );
}
|