Thursday 25 July 2013

Chapter 2 solutions Problem [C][i]

Question-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.
Solution-
Basic problem. you might not need to look the solution,but just for the sake of continuity .

#include<stdio.h>
int main()
{
float l,b,area,peri; 
printf("Enter the length and breadth respectively\n");
scanf("%f%f",&l,&b);
area=l*b;
peri=2*(l+b);
if(area>peri)
printf("Area is greater than perimeter\n");
else if(peri>area)
printf("Perimeter is greater than area\n");
else
printf("Both are equal\n");
return 0;
}

No comments:

Post a Comment