Tuesday, 24 December 2013

Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter. For example, the area of the rectangle with length = 5 and breadth = 4 is greater than its perimeter (c++ code)

#include<iostream>
using namespace std;
#include<conio.h>
int main()
  {
  int len,bre,area,perim;
 cout<<"Enter Length of a the rectangle : ";
 cin>>len;
 cout<<"Enter Breadth of a the rectangle : ";
 cin>>bre;
  perim=2*(len+bre);
  area=len*bre;
  if(area>bre)
  {        // "\n" is use for new line
   cout<<"\nYes! Area["<<area<<"] is greater that its perimeter["<<perim<<"]";
  }
  else
  {
   cout<<"\nNo! Area["<<area<<"] is not greater that its perimeter["<<perim<<"]";
  }
  getch();
  return 0;

  /*  Letuswithc:

       this page is designed to help you learn C or C++.
  Understandable C and C++ programming tutorials, compiler reviews, source code, tips and tricks. 
         */
}

No comments:

Post a Comment