62 570
Assignments Done
99%
Successfully Done
In June 2018

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.


Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions