Area OR Perimeter
Write a program to obtain length and breadth of a rectangle and check whether its area is greater or perimeter is greater or both are equal.
Input:
- First line will contain the length of the rectangle.
- Second line will contain the breadth of the rectangle.
Output:
Output 2 lines.
In the first line print "Area" if area is greater otherwise print "Peri" and if they are equal print "Eq".(Without quotes).
In the second line print the calculated area or perimeter (whichever is greater or anyone if it is equal).
Constraints
Sample Input:
1
2
Sample Output:
Peri
6
EXPLANATION:
Area = 1 * 2 = 2
Peri = 2(1 + 2) = 6
Since Perimeter is greater than Area, hence the output is
Peri
6
SOLUTION USING C LANGUAGE:-
#include <stdio.h> int main(void) { int L,B,area,perimeter; scanf("%d\n%d\n",&L,&B); area=L*B; perimeter=2*(L+B); if(area>perimeter) { printf("Area\n"); printf("%d\n",area); } else if(perimeter>area) { printf("Peri\n"); printf("%d\n",perimeter); } else { printf("Eq\n"); printf("%d\n",area); } // your code goes here return 0; }
No comments:
Post a Comment