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
Post a Comment