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:
- Hello World in C
C
// Simple C program to// display "Hello World"// Header file for// input output functions#include <stdio.h>// main function -// where the execution of// program beginsintmain(){// prints hello worldprintf("Hello World");return0;}chevron_rightfilter_none - Hello World in C++
C++
// Simple C++ program to// display "Hello World"// Header file for// input output functions#include <iostream>usingnamespacestd;// main function -// where the execution of// program beginsintmain(){// prints hello worldcout <<"Hello World";return0;}chevron_rightfilter_none - Hello World in C#
C#
// C# program to print Hello World!usingSystem;// namespace declarationnamespaceHelloWorldApp {// Class declarationclassGeeks {// Main MethodstaticvoidMain(string[] args){// statement// printing Hello World!Console.WriteLine("Hello World");// To prevents the screen from// running and closing quicklyConsole.ReadKey();}}}chevron_rightfilter_none - Hello World in Java
Java
// This is a simple Java program.// FileName : "HelloWorld.java"classHelloWorld {// Your program begins// with a call to main().// Prints "Hello, World"// to the terminal window.publicstaticvoidmain(String args[]){System.out.println("Hello World");}}chevron_rightfilter_none - Hello World in Python
Python
# Python code for "Hello World"print("Hello World")chevron_rightfilter_none - Hello World in Perl
Perl
#!/usr/bin/perl# Modules usedusestrict;usewarnings;# Print functionprint("Hello World\n");# To run the code refer:chevron_rightfilter_none - Hello World in Scala
Scala
// Scala program to print Hello World!objectGeeks{// Main Methoddefmain(args:Array[String]){// prints Hello Worldprintln("Hello World")}}chevron_rightfilter_none - Hello World in Go
Go
// Go program to print Hello World!package mainimport"fmt"// Main functionfuncmain(){// prints Hello Worldfmt.Println("!... Hello World ...!")}chevron_rightfilter_none - Hello World in PHP
PHP
<!DOCTYPE html><html><body><?phpecho"Hello World";?></body></html>chevron_rightfilter_none - Hello World in HTML
HTML
<html><header><title></title></header><body>Hello World</body></html>chevron_rightfilter_none - Hello World in JavaScript
JavaScript
<script>// using console.logconsole.log('Hello World');</script>chevron_rightfilter_none
Below are the codes of all the languages:
C
// Simple C program to // display "Hello World" // Header file for // input output functions #include <stdio.h> // main function - // where the execution of // program begins int main() { // prints hello world printf("Hello World"); return 0; } |
C++
// Simple C++ program to // display "Hello World" // Header file for // input output functions #include <iostream> using namespace std; // main function - // where the execution of // program begins int main() { // prints hello world cout << "Hello World"; return 0; } |
C#
// C# program to print Hello World! using System; // namespace declaration namespace HelloWorldApp { // Class declaration class Geeks { // Main Method static void Main(string[] args) { // statement // printing Hello World! Console.WriteLine("Hello World"); // To prevents the screen from // running and closing quickly Console.ReadKey(); } } } |
Java
// This is a simple Java program. // FileName : "HelloWorld.java" class HelloWorld { // Your program begins // with a call to main(). // Prints "Hello, World" // to the terminal window. public static void main( String args[]) { System.out.println("Hello World"); } } |
Python
# Python code for "Hello World" print("Hello World") |
Perl
#!/usr/bin/perl # Modules used use strict; use warnings; # Print function print("Hello World\n"); # To run the code refer: |
Scala
// Scala program to print Hello World! object Geeks { // Main Method def main(args: Array[String]) { // prints Hello World 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> |
Output:
Hello World
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
Recommended Posts:
- Writing first C++ program : Hello World example
- Beginning Java programming with Hello World Example
- HTML Course | First Web Page | Printing Hello World
- JS++ | Program to print Hello World
- Hello World Program in Perl
- OpenMP | Hello World program
- Print "Hello World" in C/C++ without using any header file
- Print Hello World without semicolon in C/C++
- Print "Hello World" with empty or blank main in C++
- Hello World in C#
- Hello World in Scala
- Hello World in Golang
- Hello World in Kivy
- PyQt Hello World
- Hello World in Tkinter
- Print Hello World Without using a Semicolon in Java
- Difference between while(1) and while(0) in C language
- Perl | Loops (for, foreach, while, do...while, until, Nested loops)
- Scala | Loops(while, do..while, for, nested loops)
- while and do while Loop in Scala
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

