simple hello world program in C++

In this page, we will discuss following structure of a program in C++ are follows,

Download this as PDF format header file, cout statement and cin statement in C++

header file in C++

In C++, before making a program we include some system library file in the header of the program. these files are called header file. These files contain a lot of functions that have a code to perform different task. To use these functions in a program, we have to include their file (within which they define) in the program header.

Here is syntax to include a header file in the program.



it can be possible that a function can be defined in more than one header file like exit() functions are defined in both header file stlib and process

All these functions are used further in this tutorial.

cout statement  C++

cout statement used to print the messages or results on a monitor screen because is used an output operation so its also called output statement in C++


here, << called output operator or insertion operator.

cin statement in C++

cin is an input statement that reads the value of a variable at run-time when the program is executed, values are given by an Output device (such as a keyboard).





where >> called output operator or extraction operator.

In the variable, the store value is printed by the output statement.



simple Hello Program in C++

The below program based on Dev C++,

Here is the Program

using namespace std;

int main()
  cout<<"Hello world";
  return 0;


Hello World


    • iostream is a header file.
    • main() is a function that is the starting point of a program. Here the int type data-type indicates that main() function is returning 0.

Things to know

  • In C ++, both statements (cout, cin) are terminated by semicolon (;).
  • Both cout and cin are defined under in iostream-class so we have to declare their header file ( iostream ) before using them.
  • In coutstatement the message is written within double quotes, whereas in the cin statement double quotes are not used to read the value of any variable.
  • Print a variable’s value in the Program, cout statement will be used without quotes.

Let’s understand header file in more detail,

what is header file in C++ ?

In a simple word,

Because they are usually included in the header of the program, they are called header files. You can understand a header file as a folder in a computer, which contains many files/classes.

In the program, the file we need to use, we include that header file in the header section of that program as you can see in the above program, in which we have printed a message “Hello world” for which We have included the header file named iostream in the header section of the program.
Because cout is an output statement that works to print the message on the monitor screen, so whenever we have to print a message in the program, we have to include its header file in the program..

Similarly, be it C++ or any language, to do any advance work, we include their header file in the program Read this string library in C++

The concept of header files is an advanced feature where you can create your own header files as well. But for now you can skip it

previous- Introduction of C++ Programming

next- token and keyword in C++

Like it?

4 thoughts on “simple hello world program in C++”

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version