C++ Program to print Hello World

C++ is a much easier language than C and it will be easy to learn other programming languages like java, python, etc after learning C++. It is a general-purpose multi-paradigm language.

“Hello world” program is a simple program to display the message "Hello, World!" on the screen. This is the basic level program to introduce a new programming language. This is used to illustrate a language’s basic syntax. A text will be passed through the output function of the particular programing language. Supportive functions and arguments will be used to help us to make the string display on the screen.

How to implement the "Hello, World" program in C++

  1. In C++ any line starting with // is considered a comment. If we want to pass any message to the user then this option can be used.
  2. C++ uses different header files to provide information that is necessary for the program. Here the basic input-output service file is used.  A preprocessor directive #include is used to include the contents of the iostream file in our program.
  3. The program execution always begins with the main() function. This is the entry of any C++ program. The function starts and ends with curly braces.
    Int main()
    {
    …..
    }
  4. 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

  5. Cout is an object of class Iostream defined in the iostream header file. It is used to print the output on the screen
  6. ‘;’ is used to mark the end of a statement
  7. Finally, return a value of 0. This is to exit the program. Or the program ends with this statement. 
     

ALGORITHM

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  return 0

C++ Source Code

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

#include <iostream>

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

OUTPUT

Hello World!