In this program, you will learn how to print Hello World program in C++. The Beginning of Every language starts with the Hello World Program.

We will learn the different ways to print Hello world program in C.

1. Hello World Program in C++

In this program, we will print the “Hello World” on the screen.

// A hello world program in C++
	using namespace std;
	int main()
		cout << "Hello World!";
		return 0;


hello world program in c++



The first line in our program is a comment line. Each line that begins with two slice signs (/) are viewed as remarks and will have no impact on the conduct or result of the program.

(Words between/* and */will likewise be considered as remarks (old-style remarks)). Use remarks in your projects to clarify troublesome segments, yet don’t try too hard. It is additionally regular practice to begin each program with a concise portrayal of what the program will do.


Lines starting with the hash sign (#) are utilized by the compilers pre-processor. For this situation the order #include advises the pre-processor to incorporate the iostream standard record.

This document iostream incorporates the announcements of the essential standard info/yield library in C++. (Consider it to be including additional lines of code that add usefulness to your program).

Using namespace std:

All the components of the standard C++ library are pronounced inside what is known as a namespace. For this situation the namespace with the name std. We put this line in to pronounce that we will utilize the usefulness offered in the namespace std.

This line of code is utilized continuously in C++ programs that utilize the standard library. You will see that we will utilize it in the greater part of the source code remembered for these instructional exercises.

int main():

int is what is known as the arrival esteem (for this situation of the sort whole number. Number is an entire number). What is utilized for will be clarified further down.

Each program must have a primary() work. The fundamental capacity is where all C++ programs start their execution. The word principle is trailed by a couple of round sections.

That is on the grounds that it is a capacity affirmation (Functions will be clarified in more detail in a later instructional exercise). It is conceivable to encase a rundown of parameters inside the round sections.

{} (Curly Braces):

The two curly brackets are utilized to show the start and the finish of the function main. (Additionally called the body of a program). Everything contained inside these curly brackets is the thing that the capacity does when it is called and executed. In the coming instructional exercises, you will see that numerous different statements utilize curly brackets.

cout << “Hello World”;

This line is a type of C++ statement. A type of statement which can deliver an impact. For this situation, the statement will print something to our screen.

(There is additionally a standard information stream that will be clarified in another instructional exercise). In this, a grouping of characters (Hello World) will be sent to the standard output stream.

The words Hello World must be between ” “, yet the ” won’t be imprinted on the screen. They show that the sentence starts and where it will end.

As should be obvious the statement closes with a semicolon (;). The semicolon is utilized to check the finish of the statement. The semicolon must be put behind all statements in C++ programs. Along these lines, recollect this. One of the regular mistakes is to neglect to incorporate a semicolon after statements.

return 0:

The return statement makes the principle work finish. You may restore a return statement (for this situation a zero) yet it relies upon how you start your capacity primary( ).

We said that primary ( ) will restore an int (whole number). So we need to return something (for this situation a zero). A zero ordinarily shows that everything went alright and a one regularly demonstrates that something has turned out badly.

(This is standard practice. In the wake of running a UNIX/Linux program there is regularly a keep an eye on the arrival code).


In a program as Hello World, it appears to be a moronic activity. Yet, as the projects become progressively unpredictable, you will see that it makes the code increasingly meaningful.

Along these lines, consistently use indentations and comments to make the code progressively understandable. It will make your life (programming life in any event) a lot simpler if the code turns out to be increasingly mind-boggling.

2. Hello World Program in C++ Using Class

using namespace std;
class Message
    void display() {
      cout << "Hello World";
int main()
    Message t;    
    return 0;


hello world program in c++

Also Read: