C++ Program to print Hello World

September 7, 2021, Learn eTutorial

C++ is an object-oriented programming language and is a much easier language than C. If you learn C++ you can easily learn all other languages that are object-oriented like JAVA, etc. It is a general-purpose multi-paradigm language.

The “Hello world” program is a simple program to display the message "Hello, World!" on the screen. This is the basic level program for introducing a new programming language. This is used to illustrate a language’s basic syntax. 

How to write a C++ program to print "Hello, World" 

Before going to the program you have to read the below points which are the basics of a C++ program working. 

  • In C++ any line starting with '//' is considered a comment. 
  • C++ uses different header files to provide information that is necessary for the program. Here the basic input-output header file 'iostream' is used.
  • A preprocessor directive #include is used to include the contents of the iostream file in our program.
  • C++ needs a main() function where the program execution begins. 
  • std::cout is used to print any message on the screen. The content must be inside the quotation marks and followed by <<.

    Example: Std::cout<< string

  • ‘;’ is used to mark the end of a statement
  • Finally, return a value of 0. This is to exit the program. Or the program ends with this statement. 


STEP 1: Call the header file #include

STEP 2: Call the main function int main()

STEP 3: Call the function std::count to print the message  <<"Hello, World!"

STEP 4: Exit the program and return 0

C++ Source Code

                                          // Simple C++ Program to print "Hello World"

#include <iostream>

int main() {
    std::cout << "Hello World!";
    return 0;


Hello World!