The lessons in the previous posts are quite enough to be applied to a small program, for example to calculate the area of a rectangle, first we have to know the formula.
It is Area = width * long
So we can make the syntax like the example below:
#include "iostream.h"
#include "conio.h"
main()
{
int area, wt, lg;
cout<< "Calculate Rectangle Area";
cout<< "\n\nInsert width: ";
cin>> wt;
cout<< "Insert long: ";
cin>> lg;
area = wt*lg;
cout<< "The Area of the Rectangle is: "<< area;
getch();
}
The result will like the pictures below:
0 comments:
Post a Comment