Sunday, August 31, 2014

Given the length and breadth of a rectangle, write a program to find whether the area of the rectangle is greater than its perimeter

Hint: The area of the rectangle with length = 5 and breadth = 4 is greater than its perimeter.
          Perimeter of rectangle = 2* (length + breadth)
          Area of rectangle = length * breadth

Code

#include<stdio.h>
#include<conio.h>
int main()
{
int length,breadth,perimeter,area;

printf("enter length and breadth: ");
scanf("%d%d",&length,&breadth);

perimeter=2*(length+breadth);
area=length*breadth;

if(area>perimeter)
printf("\narea is greater than perimeter");
else if(area<perimeter)
printf("area is lesser than perimeter");
else
printf("area and perimeter are equal");

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

area is greater than perimeter

No comments :

Post a Comment

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact