You are given four edges as integers.Your task is to tell whether it is possible to form a rectangle with these edges?

Example:

Input: 2,5,2,5

Output:Yes

Login

0 votes

Best answer

Compare any two edges, If they are equal then to make a rectangle other two edges should be equal.

```
#include<iostream>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
//Check all possible combinations
if((a==b&&c==d)||(a==c&&b==d)||(a==d&&b==c))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
}
```

- All categories
- Interview Question (230)
- Coding(Hiring) (42)
- Competitive Coding (5)
- Phone Interview (5)
- Written Test (15)
- Algorithm (12)
- Puzzle (4)

...