Sample Program 1

Let’s consider a simple example to explain int data type. In this example we take two integers, add them and display the answer on the screen. 

The code of the program is written below. 

#include <iostream.h>

main()

{

            int x;

            int y;

            int z;    

            x = 5;

            y = 10;

            z = x + y;

            cout << “x = “;

            cout << x;

            cout << “ y=“;

            cout << y;

            cout <<“ z = x + y = “;

            cout << z;

}

 

 

 

Previous

 

 

TOC

 

 

Next