CPP Cafe

The Menu

 

Home -> Menu -> rectangle

rectangle


/* Prompts user to enter the length and width of a rectangle and
then calculates the area and perimeter of the rectangle*/

#include <iostream.h>
#include <stdlib.h>

int main()
{
int length;
int width;
int perimeter;
int area;

cout<<"Please enter the width of a rectangle in inches:"<<endl;
cin>>width;
cout<<"You have entered:"<<" "<<width<<endl;
cout<<"Please enter the length of the rectangle in inches:"<<endl;
cin>>length;
cout<<endl;
cout<<"You have entered:"<<" "<<length<<endl;
area = length * width;
perimeter = (length *2) + (width * 2);
cout<<endl;
cout<<"The area of the rectangle is:"<<" "<<area<<" "<<" square inches" <<endl;
cout<<"The perimeter of the rectangle is:"<<" "<<perimeter<<" "<<"inches"<<endl;
cout<<"Have a nice day!"<<endl;

 

system("PAUSE");
return 0;
}