Hello World Program : First program while learning Programming
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
Recommended Posts:
- JS++ | Program to print Hello World
- OpenMP | Hello World program
- Writing first C++ program : Hello World example
- Hello World Program in Perl
- 5 Most Difficult Programming Languages of the World
- Beginning Java programming with Hello World Example
- Top 10 Programming Languages of the World – 2019 to begin with…
- Why learning C Programming is a must?
- Python program to find GSoC organisations that use a Particular Programming Language
- Why is Python the Best-Suited Programming Language for Machine Learning?
- C program to print a string without any quote (singe or double) in the program
- Learning Model Building in Scikit-learn : A Python Machine Learning Library
- ML | Reinforcement Learning Algorithm : Python Implementation using Q-learning
- C program to detect tokens in a C program
- How to Start Learning Machine Learning?
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.

