Please Fill out the Feedback Form for Code Radius

Area OR Perimeter : AREAPERI | CodeChef Solution

1 min read

 

Problem

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 Format

  • First line will contain the length (L) of the rectangle.
  • Second line will contain the breadth (B) of the rectangle.

Output Format

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

cpp
#include <iostream> using namespace std; // Solution from : Code Radius [ https://radiuscode.blogspot.com/ ] int main() { // your code goes here int l,b,p,a; cin>>l; cin>>b; p=2*(l+b); a=l*b; if(p>a) { cout<<"Peri"<<endl; cout<<p; } else if(p<a) { cout<<"Area"<<endl; cout<<a; } else if(p==a) { cout<<"Eq"<<endl; cout<<p; } return 0; }
Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem Write a program to obtain a number NN and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1. Please Share this article... …
  • Problem Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash …
  • Problem The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Ou…
  • Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.Relational Operators are operators which check relati…
  • Problem Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him…
  • Problem In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b seconds are added to this player's clock. Ti…

Post a Comment