Hello Programmers In this post, you will know how to solve the Area OR Perimeter Codechef Solution. The Problem Code: AREAPERI

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.
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:
- 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
- 1≤L≤10001≤L≤1000
- 1≤B≤1000
Example
Sample Input 1
1
2
Sample Output 1
Peri
6
Area OR Perimeter CodeChef Solutions in JAVA
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int L = sc.nextInt(); int B = sc.nextInt(); System.out.println(solve(L, B)); sc.close(); } static String solve(int L, int B) { int area = L * B; int perimeter = (L + B) * 2; String comparison; if (area > perimeter) { comparison = "Area"; } else if (area < perimeter) { comparison = "Peri"; } else { comparison = "Eq"; } return String.format("%s\n%d", comparison, Math.max(area, perimeter)); } }
Area OR Perimeter CodeChef Solutions in CPP
#include <iostream> using namespace std; int main() { // your code goes here float l,b,area,peri; cin>>l>>b; area=l*b; peri=2*(l+b); if(area>peri){ cout<<"Area"<<endl; cout<<area; }else if(peri>area){ cout<<"Peri"<<endl; cout<<peri; }else if(area==peri){ cout<<"Eq"<<endl; cout<<area; } return 0; }
Area OR Perimeter CodeChef Solutions in Python
l = int(input()) b = int(input()) a = l*b p = 2*l+2*b if a>p: print("Area") print(a) elif a==p: print("Eq") print(a) else: print("Peri") print(p)
Disclaimer: The above Problem (Area OR Perimeter) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.
Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.
Next: Chef Restaurant Codechef Solution