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.
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 Beginner {
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
print ( "Hello World" )
print (
)
|
Output
Hello World
Hello
world
Perl
#!/usr/bin/perl
use strict;
use warnings;
print ( "Hello World\n" );
|
Scala
object Beginner
{
def main(args : Array[String])
{
println( "Hello World" )
}
}
|
C
package main
import "fmt"
func
main()
{
fmt.Println( "!... Hello World ...!" )
}
|
PHP
<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World" ;
?>
</body>
</html>
|
Output
<!DOCTYPE html>
<html>
<body>
Hello World
</body>
</html>
HTML
< html >
< header >< title ></ title ></ header >
< body >
Hello World
</ body >
</ html >
|
JavaScript
<script>
console.log( 'Hello World' );
</script>
|
Julia
/ / Julia program
println( "Hello World" )
|
15. Hello World in Solidity
Solidity
pragma solidity ^0.8.16;
contract HelloBeginner{
function renderHelloBeginner () public pure returns (string memory) {
return "Hello World" ;
}
}
|
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" )
}
|
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 Beginner {
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 Beginner
{
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 helloBeginner {
function renderHelloBeginner () 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!" );
}
|