Advertisement
joeydrizz

Untitled

Sep 16th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. double length;
  6. double width;
  7. double areaofrectangle;
  8. double perimeterofrectangle;
  9.  
  10. cout<<"enter the length of rectangle"<<endl;
  11. cin>>length;
  12.  
  13. cout<<"enter the width of rectangle"<<endl;
  14. cin>>width;
  15.  
  16. areaofrectangle = length*width;
  17. perimeterofrectangle = 2*areaofrectangle;
  18.  
  19. if(length==width)
  20. {
  21. cout<<"Can't compute base because a rectangle can't have both sides equal"<<endl;
  22. }
  23.  
  24. else {
  25.  cout<<"the area of the rectangle is "<< areaofrectangle <<endl;
  26.  
  27. cout<<" the perimeter of the rectangle is "<<perimeterofrectangle<<endl;
  28.  
  29. }
  30. return 0;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement