Area OR Perimeter||codechef||beginner solution ||programming info

Area OR Perimeter

Write a program to obtain length (L) and breadth (B) 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 (L) of the rectangle.
  • Second line will contain the breadth (B) 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

  • 1L1000
  • 1B1000

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;
}

Share:

No comments:

Post a Comment

Translate

Recommended platforms

  1. codechef
  2. hackerrank
  3. codeforces
  4. leetcode
  5. hackerearth

Popular Posts

programming_info. Powered by Blogger.

Blog Archive

Recent Posts

other platforms

  • geeks for geeks
  • w3schools
  • codepen
  • skillshare
  • udemy

Pages

reader support Support