Answer to Question #58165 in C++ for Isidro Gonzalez

Question #58165
The area of a rectangle is the rectangle's length times its width. Write an interactive program that asks for the length and width of two rectangles. The program should compute the areas of the rectangles and tell the user which rectangle has the greatest area, or if the areas are the same. Your variable names should reflect this.
1
Expert's answer
2016-03-09T08:36:42-0500
#include <iostream>
using namespace std;
int main()
{
double width1, length1,
width2, length2;
cout<<"Input width for rectangle 1: ";
cin>>width1;
cout<<"Input length for rectangle 1: ";
cin>>length1;

cout<<"Input width for rectangle 2: ";
cin>>width2;
cout<<"Input length for rectangle 2: ";
cin>>length2;

double Area1,Area2;
Area1=width1*length1;
Area2=width2*length2;
if(Area1>Area2)
cout<<"Area of first rectangle is bigger!";
else
if(Area1<Area2)
cout<<"Area of second rectangle is bigger!";
else
cout<<"Areas of rectangles is equal!";

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS