- Version
- Download 16
- File Size 1.25 KB
- File Count 1
- Create Date May 5, 2016
- Last Updated May 5, 2016
Compute the Area and Perimeter of the Rectangle in C++
Compute the Area and Perimeter of the Rectangle in C++
Example program in c++ that ask the user to input the length and width of a rectangle, the program will then compute and display the area and perimeter of the rectangle.
Codeblocks is used as the ide for this program. It is an open source, cross-platform ide.
Source code:
#include < iostream >
using namespace std;
int main()
{
int area, perimeter, length, width;
cout <<"Please enter the length of rectangle: "<< endl;
cin >> length;
cout <<"Please enter the width of rectangle: "<< endl;
cin >> width;
area=length*width;
perimeter = 2 * (length*width);
cout << "The area is: " << area << endl;
cout << "The perimeter is: " << perimeter << endl;
return 0;
}