The area of a rectangle is the rectangle’s length times its width. Write a program that asks for the length and width of two rectangles. The program should tell the user which rectangle has the greater area, or if the areas are the same.

Respuesta :

Answer:

Using c++

Check the image for colors.

Step-by-step explanation:

#include <iostream>

using namespace std;

int main()

{

   float length1,length2,width1,width2,area1,area2;

   

   cout<<"length of Rectangle 1\n";

   cin>>length1;

   cout<<"\nwidth of Rectangle 1\n";

   cin>>width1;

   cout<<"\nlenght of Rectangle 2\n";

   cin>>length2;

   cout<<"\nwidth of Rectangle 2\n";

   cin>>width2;

   

   area1=length1*width1;

   area2=length2*width2;

   

   if (area1<area2)

   {cout << "\nRectangle 2 has greater area";}

   else {

               if (area1>area2)

                  {cout << "\nRectangle 1 has greater area";}

               else {cout << "\nAreas are the same";}

         }

   

   return 0;

}

Ver imagen anapaty049