This is a simple “Hello World” C++ program to display “Hello World” text on the screen.

Typically, the best way to learn programming is by writing code. The first program beginners write is “Hello World” which is often used to illustrate the syntax of a programming language. You can take a look at the list of Hello World Programs in 300 Programming Languages to see how “Hello World” looks like in different programming languages.

Let’s take a look at how “Hello World” program looks in C++.

Example 1: C++ Hello World Program

Output of C++ Program

The first line of this program is a comment which is indicated by double forward slashes i.e. //

Then lines beginning with a hash sign (#) are directives read and interpreted by what is known as the preprocessor in C++.

Every C++ program run from the main() function regardless of where the function is actually located within the code.

The cout  is the standard output stream which prints the “Hello World” text on the computer screen.

Finally, the return 0;  is the exit status of the program which causes the C++ program to terminate.

Example 2: C++ Hello World Program

Output of C++ Program