Codechef Problems: Rectangle and Square (RECSQ)

 Problem Statement: 

https://www.codechef.com/problems/RECSQ


Solution: 

Given, 
    A : Length of Rectangle 
    B : Breadth of Rectangle 
    C : Side of a Square 

To find: check if area of square and rectangle are equal 

area of Rectangle = A * B  [ length * breadth ] 
area of Square = C * C  [ side * side ] 

condition 1 : Area of Rectangle = Area of Square 
Output : Yes 

condition 2 : Area of Rectangle != Area of Square 
Output : No

Code Solution: 

#include <bits/stdc++.h>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    int area_rect = a * b;
    int area_sq = c * c;

    if (area_sq == area_rect) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Comments

Popular posts from this blog

Codechef Problems: Triangles (TRIANGLE7)

Codechef Problems: Assignment Due (P1_175)

Codechef Problems : Happy New Year! (NEWYEAR)