Answer to Question #4839 in C++ for matt

Question #4839
the are 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 ares are the same.
1
Expert's answer
2011-10-27T08:18:03-0400
#include <iostream.h>
#include <conio.h>
main(){
float a1,b1,a2,b2,s1,s2;
cout<<"Enter the lenght of the first rectangle:";
cin>>a1;
cout<<"Enter the width of the first rectangle:";
cin>>b1;
cout<<"Enter the lenght of the second rectangle:";
cin>>a2;
cout<<"Enter the width of the second rectangle:";
cin>>b2;
s1 = a1*b1;
s2 = a2*b2;
if (s1>s2) cout<<"First rectangle is larger than the second";
if (s1<s2) cout<<"Second rectangle is larger than the first";
if (s1==s2) cout<<"Rectangles has equal areas";
getch();
}

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