The Wayback Machine - https://web.archive.org/web/20241004222500/https://www.geeksforgeeks.org/hello-world-program-first-program-while-learning-programming/
Open In App

Hello World Program : First program while learning Programming

Last Updated : 16 Feb, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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




// 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;
}


Output

Hello World

2. Hello World in C++ 

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;
}


Output

Hello World

3. Hello World in C# 

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();
    }
}
}


Output

Hello World

4. Hello World in Java

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");
    }
}


Output

Hello World

5. Hello World in Python

Python




# Python code for "Hello World"
 
print("Hello World")
 
 
#python code for "Hello world" in multiple lines
 
print("""Hello
world""")


Output

Hello World
Hello
world

6. Hello World in Perl

Perl




#!/usr/bin/perl
 
# Modules used
use strict;
use warnings;
 
# Print function
print("Hello World\n");
 
# To run the code refer:


Output

Hello World

7. Hello World in Scala

Scala




// Scala program to print Hello World!
 
object Geeks
{
 
    // Main Method
    def main(args: Array[String])
    {
 
        // prints Hello World
        println("Hello World")
    }
}


Output

Hello World

8. Hello World in Go

C




// Go program to print Hello World!
 
package main
 
    import "fmt"
 
    // Main function
    func
    main()
{
 
    // prints Hello World
    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>
 
// using console.log
console.log('Hello World');
</script>


12. Hello World in Julia

Julia




// Julia program
println("Hello World")


13. Hello World in R

R




# Code
cat('Hello World')


14. Hello world in Ruby

Ruby




# code
puts "Hello World"


Output

Hello World

15. Hello World in Solidity

Solidity




// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.16;
/// @title A contract for demonstrating Hello World program
/// @author Jitendra Gangwar
/// @notice For now, this contract return the Hello World string
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




% Code
fprintf('Hello World!');
% You can also use
disp('Hello World!');


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>


Julia




println("Hello World")


Ruby




puts "Hello World"


R




cat('Hello World')


Go




package main
   
import "fmt"
   
// Main function
func main() {
   
    fmt.Println("Hello World")
}


Javascript




<script>
 
// using console.log
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




% Code
fprintf('Hello World!');
% You can also use
disp('Hello World!');


Rust




fn main() {
    println!("Hello, world!");
}


Output

Hello World


Similar Reads

Writing First C++ Program - Hello World Example
C++ is a widely used Object Oriented Programming language and is relatively easy to understand. The "Hello World" program is the first step towards learning any programming language and is also one of the most straightforward programs you will learn. The Hello World Program in C++ is the basic program that is used to demonstrate how the coding proc
4 min read
Hello World in R Programming
When we start to learn any programming languages we do follow a tradition to begin HelloWorld as our first basic program. Here we are going to learn that tradition. An interesting thing about R programming is that we can get our things done with very little code. Before we start to learn to code, let's see the process of where to download the neede
2 min read
HTML Course First Web Page Printing Hello World
Course Navigation So far, we already have learned about the structure of an HTML document, tags etc. Let us use this knowledge to create our first web page which will print the text "Hello World!" on the screen. Open your text editor, and type the below code in it and save it with the name "index.html". Note: HTML files are saved with the file exte
2 min read
Difference between For, While and Do-While Loop in Programming
For Loop, While Loop, and Do-While Loop are different loops in programming. A For loop is used when the number of iterations is known. A While loop runs as long as a condition is true. A Do-While loop runs at least once and then continues if a condition is true. For Loop in Programming:The for loop is used when you know in advance how many times yo
5 min read
Difference between While Loop and Do While Loop in Programming
While loop and Do while loop concepts are fundamental to control flow in programming, allowing developers to create loops that repeat a block of code based on certain conditions. The choice between "while" and "do while" depends on the specific requirements of the program and the desired behavior of the loop. It is important for a beginner to know
4 min read
Hello World program in Kotlin
Hello, World! is the first basic program in any programming language. Let's write the first program in Kotlin programming language. The "Hello, World!" program in Kotlin: Open your favorite editor notepad or notepad++ and create a file named firstapp.kt with the following code. // Kotlin Hello World Program fun main(args: Array<String>) { pri
2 min read
JS++ | Program to print Hello World
In this tutorial, you’ll write your first JS++ program. The program’s purpose will be to get an HTML document to display "Hello World!" when opened with a web browser. Visual Studio Code Before you can start writing code, you’ll need to decide which application to use to do the writing. While in theory, you could use a standard text editor such as
5 min read
Hello World Program in Perl
Perl programming language is exclusively designed for text processing purposes. Its abbreviation denotes Practical Extraction and Report Language. It is compatible on various platforms, such as Windows, Mac OS, and almost all versions of UNIX. Hello World! program in every programming language gives the beginner programmer a leap in proceeding furt
3 min read
C# Program to Print Hello World Without Using WriteLine
Hello World program is the most basic program of any programming language. It prints "Hello world" on the screen. In this article, we will display "Hello World" without using WriteLine Method. So to do this task we use the following methods: Console.OpenStandardOutput(): This method is used to acquire the standard output stream.Console.ReadKey(): T
2 min read
Java Hello World Program
Java is one of the most popular and widely used programming languages and platforms. Java is fast, reliable, and secure. Java is used in every nook and corner from desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet. In this article, we will learn how to write a simple Java Program. Steps to Implem
5 min read
Hello World in Scala
The Hello World! the program is the most basic and first program when you dive into a new programming language. This simply prints the Hello World! on the output screen. In Scala, a basic program consists of the following: object Main Method Statements or Expressions Example: // Scala program to print Hello World! object Geeks { // Main Method def
2 min read
Hello World in Ruby
Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. Hello World the program is the most basic and first program when we start a new programming language. This simply prints Hello World on the screen. Below is the program to write hello world". How to run a Ruby Program on different platform? With Online IDE : We ca
2 min read
Hello World in Golang
Hello, World! is the first basic program in any programming language. Let’s write the first program in the Go Language using the following steps: First of all open Go compiler. In Go language, the program is saved with .go extension and it is a UTF-8 text file.Now, first add the package main in your program:package mainEvery program must start with
2 min read
Hello World in Kivy
Kivy is an opensource multi-platform GUI development library for Python and can run on iOS, Android, Windows, OS X, and GNU/Linux. It helps develop applications that make use of innovative, multi-touch UI. The fundamental idea behind Kivy is to enable the developer to build an app once and use it across all devices, making the code reusable and dep
2 min read
PyQt Hello World
There are so many options provided by Python to develop GUI application and PyQt5 is one of them. PyQt5 is cross-platform GUI toolkit, a set of python bindings for Qt v5. One can develop an interactive desktop application with so much ease because of the tools and simplicity provided by this library. Installation : pip install PyQt5 In this article
2 min read
Hello World in Tkinter
Tkinter is the Python GUI framework that is build into the Python standard library. Out of all the GUI methods, tkinter is the most commonly used method as it provides the fastest and the easiest way to create the GUI application. Creating the Hello World program in Tkinter Lets start with the 'hello world' tutorial. Here is the explanation for the
2 min read
Print Hello World Without using a Semicolon in Java
Every statement in Java must end with a semicolon as per the basics. However, unlike other languages, almost all statements in Java can be treated as expressions. However, there are a few scenarios when we can write a running program without semicolons. If we place the statement inside an if/for statement with a blank pair of parentheses, we don’t
2 min read
How to write a simple Flask API for hello world?
Prerequisites: Introduction to REST API REST stands for Representational State Transfer and is an architectural style used in modern web development. It defines a set of rules/constraints for a web application to send and receive data. In this article, we are going to learn how to create a simple REST API that returns 'Hello World', with the help o
3 min read
Hello World Example using Stuts2
Apache Struts 2 is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller architecture. In this article, we will see how we can create a simple Hello World application in Struts 2. We are going to use Eclipse IDE so that all
4 min read
Python Falcon - Hello World
Falcon is a powerful and minimalistic Python framework for building high-performance APIs. In this article, we'll take a closer look at Falcon and build a simple "Hello World" application using the WSGI (Web Server Gateway Interface) specification. What is Falcon?Falcon is an open-source Python web framework that follows the minimalist philosophy.
2 min read
Spring Boot - Hello World
Spring Boot is built on the top of the spring and contains all the features of spring. And is becoming a favorite of developers these days because of its rapid production-ready environment which enables the developers to directly focus on the logic instead of struggling with the configuration and setup. Spring Boot is a microservice-based framework
4 min read
Print "Hello World" in C/C++ without using any header file
Write a C/C++ program that prints Hello World without including any header file. Conceptually it's seems impractical to write a C/C++ program that print Hello World without using a header file of "stdio.h". Since the declaration of printf() function contains in the "stdio.h" header file. But we can easily achieve this by taking the advantage of C p
2 min read
Print Hello World without semicolon in C/C++
Every statement in C++ must end with a semicolon as per basics. However, unlike other languages, almost all statements in C++ can be treated as expressions. However there are few scenarios when we can write a running program without semicolon. If we place the statement inside an if/switch/while/macro statement with a blank pair of parentheses, we d
2 min read
Print "Hello World" with empty or blank main in C++
Write a program in C++ that prints "Hello World", it has a main function and body of main function is empty. Following are three different solutions. We can create a global variable and assign it return value of printf() that prints "Hello World" C/C++ Code // C++ program to print something with empty main() #include &lt;bits/stdc++.h&gt; i
2 min read
"Hello World" In 30 Different Languages
In this article, we are going to see how to print "Hello World" in 30 different languages. It includes languages like C, C++, Cobol, Scala, Matlab, C#, CoffeeScript, Delphi, Dart, Haskell, Pascal, Ruby, Python, Assembly, R, Swift, Kotlin, PHP, Java, Go, F#, Lisp, JavaScript, Algol, Perl, Tcl, TypeScript, Fortran, Bash (Unix Shell) and HTML. Now, le
13 min read
Hello World in C#
The Hello World! program is the most basic and first program when you dive into a new programming language. This simply prints the Hello World! on the output screen. In C#, a basic program consists of the following: A Namespace DeclarationClass Declaration & DefinitionClass Members(like variables, methods etc.)Main MethodStatements or Expressio
3 min read
Perl | Loops (for, foreach, while, do...while, until, Nested loops)
Looping in programming languages is a feature which facilitates the execution of a set of instructions or functions repeatedly while some condition evaluates to true. Loops make the programmers task simpler. Perl provides the different types of loop to handle the condition based situation in the program. The loops in Perl are : for Loop "for" loop
7 min read
Scala | Loops(while, do..while, for, nested loops)
Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true. Loops make the programmers task simpler. Scala provides the different types of loop to handle the condition based situation in the program. The loops in Scala are : while Loopdo..while L
5 min read
while and do while Loop in Scala
Looping in programming languages is a feature which facilitates the execution of a set of instructions/functions repeatedly while some condition evaluates to true. Loops make the programmers task simpler. Scala provides the different types of loops but in this article we understand while and do-while loops. while loop While programming there might
4 min read
Which will be faster while(1) or while(2)?
In most Programming Languages, a while loop is a control flow statement that allows code to be executed repeatedly based on a given boolean condition. The boolean condition is either true or false. while(1) & while(2) It is an infinite loop that will run till a break statement is issued explicitly. Neither while(1) nor while(2) but any integer whic
2 min read