Structure

Comments Declaration and Variables Mathematics Input/Output

C++ PROGRAM STRUCTURE

Let's look at a basic c++ program

/* Comment: The program structure of a basic c++ program has the following. */

#include <iostream.h>

main () {

     int number1, number2, answer;

    number1=5;

    number2=7;

   answer=number1+number2;

   cout << "The answer is" << answer << endl;

}

As we look at this code we find four important lessons

  1. Commenting
  2. Declarations and Variables
  3. C++ Mathematics
  4. Input/Output Statements
 

Back Home Up Next