Saturday, January 30, 2010

CHAP 2[C]i Checking if area is bigger than perimeter of rectangle

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.

void main()
{
float l,b,a,p;
printf("Input length and breadth of rectangle");
scanf("%f%f",&l,&b);
a=l*b;
p=2.0*l+2.0*b;
(a>p?printf("\nArea is larger than perimeter"):printf("\nArea is smaller than perimeter"));
}

No comments:

Post a Comment