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!";
Comments
Leave a comment