Coupon Accepted Successfully!


Structure of C++ program

The above table tells us the structure of a C++ program.

  • Let us start with an example program with the help of the above structure.
Program 1:

Line no








//first program


void main


cout<< " Welcome to my class room";


  • Line 1: It is a comment statement and non-executable statement.
  • Line 2: It is a section where the header file is included. The header file contains the executable library function which helps for the program execution.
  • Line 3: It is called the scope of a function, which says the start of the function
  • Line 4: It is a print statement which prints the content given with the double quotation mark. Each step is terminated with the help of a semi colon which is a terminator.
  • Line 5: It is the close of the scope. It says that the program is completed.

Comment Statements

  • These are statement which the compiler will not execute.
  • It is used for user identification.
  • There are two types of comment statement.
  • They are
    • Single line comment statement
      • It uses the symbol double front slash (//), which helps to give a single line comment.
      • For example
        // this is an example program
    • Multi line comment statement
      • It uses a symbol at the start with front slash and an asterisk symbol at the end of the statement an asterisk symbol and a front slash (/*--------- */)
      • It is also called as block statement
      • For example
        /* this is an example program
        It performs addition of two numbers */
Note: Comment statements are non executable statement.

Test Your Skills Now!
Take a Quiz now
Reviewer Name