C++ Hello World Program

In this tutorial you will learn about the C++ Hello World Program and its application with practical example.

C++ Hello World Program

The “Hello world!” program is a simplest program that will display some text on the screen. The “Hello world!” program is a simple yet complete program for beginners that illustrates the basic syntax of any programming language. The “Hello world!” program gives you a way to test systems and programming environment. This tutorial will guide you through writing a basic “Hello, World” program in C++ Programming.

Table Of Contents

Step 1:- Create a file called “helloworld.cpp” using a text editor program of your choice. The .cpp file extension is used to specify a C++ Program file.

Step 2:- Let’s open the “helloworld.cpp” file that we created, and put the following line of code in it and save it.

Let’s understand each and every part of the above program.

1. Comments – This is comment statements being used to provide information about the program we created.

2. #include<iostream> – This is a preprocessor statement that tells the compiler to include iostream header file. This header file contains common input/output functions being used in our C++ Program.

3. using namespace std; – This statement is used to specify a common namespace for program entities. The namespace is like a common space where program elements such as classes, structures, functions and variables available. Here std is a namespace name, this tells the compiler to look into that particular region for all the variables, functions, etc.

4. int main() – It is the entry point of our program from where the program execution begins. It is main function of our program and the execution of program begins with this function. The integer (int) is the returns type of value being return by the main () function. In the above program it returns value zero(0) of integer type.

5. cout << “Hello World!”; – The cout is an object belongs to the iostream file and it used to output/display the content between double quotes to the screen.

6. return 0; – This is a return statement that returns value 0 from the main() function which indicates that the execution of main function is successful.

Step 3:- Now, compile and run above the C++ program

Once the program is executed it will print “Hello World!”.



In this tutorial we have learn about the C++ Hello World Program and its application with practical example. I hope you will like this tutorial.