# Check if given four integers (or sides) make rectangle

Given four positive integers, determine if there’s a rectangle such that the lengths of its sides are a, b, c and d (in any order).
Examples :

```Input : 1 1 2 2
Output : Yes

Input : 1 2 3 4
Output : No

```

Approach 1 :- We will check, if any of the two integers are equal and make sure rest of two are also equal using few if else conditions.

## C++

 `// A simple program to find if given 4` `// values can represent 4 sides of rectangle` `#include ` `using` `namespace` `std;`   `// Function to check if the given` `// integers value make a rectangle` `bool` `isRectangle(``int` `a, ``int` `b, ``int` `c, ``int` `d)` `{` `    ``// Square is also a rectangle` `    ``if` `(a == b == c == d) ` `        ``return` `true``;`   `    ``else` `if` `(a == b && c == d)` `        ``return` `true``;` `    ``else` `if` `(a == d && c == b)` `        ``return` `true``;` `    ``else` `if` `(a == c && d == b)` `        ``return` `true``;` `    ``else` `        ``return` `false``;` `}`   `// Driver code` `int` `main()` `{` `    ``int` `a, b, c, d;` `    ``a = 1, b = 2, c = 3, d = 4;` `    ``if` `(isRectangle(a, b, c, d))` `        ``cout << ``"Yes"``;` `    ``else` `        ``cout << ``"No"``;` `    ``return` `0;` `}`

## Java

 `// A simple program to find if` `// given 4 values can represent ` `// 4 sides of rectangle` `class` `GFG {`   `    ``// Function to check if the given` `    ``// integers value make a rectangle` `    ``static` `boolean` `isRectangle(``int` `a, ``int` `b, ` `                               ``int` `c, ``int` `d)` `    ``{` `        ``// Square is also a rectangle` `        ``if` `(a == b && a == c && ` `            ``a == d && c == d &&` `            ``b == c && b == d) ` `            ``return` `true``;` `    `  `        ``else` `if` `(a == b && c == d)` `            ``return` `true``;` `        ``else` `if` `(a == d && c == b)` `            ``return` `true``;` `        ``else` `if` `(a == c && d == b)` `            ``return` `true``;` `        ``else` `            ``return` `false``;` `    ``}` `    `  `    ``// Driver code` `    ``public` `static` `void` `main(String[] args)` `    ``{` `        `  `        ``int` `a = ``1``, b = ``2``, c = ``3``, d = ``4``;` `        ``if` `(isRectangle(a, b, c, d))` `            ``System.out.println(``"Yes"``);` `        ``else` `            ``System.out.println(``"No"``);` `    ``}` `}`   `// This code is contributed by prerna saini.`

## Python3

 `# A simple program to find if given 4` `# values can represent 4 sides of rectangle`   `# Function to check if the given` `# integers value make a rectangle` `def` `isRectangle(a, b, c, d):` `    `  `    ``# Square is also a rectangle` `    ``if` `a ``=``=` `b ``=``=` `c ``=``=` `d:` `        ``return` `True` `        `  `    ``elif` `a ``=``=` `b ``and` `c ``=``=` `d:` `        ``return` `True` `        `  `    ``elif` `a ``=``=` `d ``and` `c ``=``=` `b:` `        ``return` `True` `        `  `    ``elif` `a ``=``=` `c ``and` `d ``=``=` `b:` `        ``return` `True` `        `  `    ``return` `False`     `# Driver code` `a, b, c, d ``=` `1``, ``2``, ``3``, ``4` `print``(``"Yes"` `if` `isRectangle(a, b, c, d) ``else` `"No"``)`     `# This code is contributed by Ansu Kumari.`

## C#

 `// A simple program to find if` `// given 4 values can represent` `// 4 sides of rectangle` `using` `System;`   `class` `GFG {`   `    ``// Function to check if the given` `    ``// integers value make a rectangle` `    ``static` `bool` `isRectangle(``int` `a, ``int` `b,` `                            ``int` `c, ``int` `d)` `    ``{` `        ``// Square is also a rectangle` `        ``if` `(a == b && a == c && a == d &&` `            ``c == d && b == c && b == d)` `            ``return` `true``;`   `        ``else` `if` `(a == b && c == d)` `            ``return` `true``;` `            `  `        ``else` `if` `(a == d && c == b)` `            ``return` `true``;` `            `  `        ``else` `if` `(a == c && d == b)` `            ``return` `true``;` `            `  `        ``else` `            ``return` `false``;` `    ``}`   `    ``// Driver code` `    ``public` `static` `void` `Main()` `    ``{`   `        ``int` `a = 1, b = 2, c = 3, d = 4;` `        ``if` `(isRectangle(a, b, c, d))` `            ``Console.WriteLine(``"Yes"``);` `        ``else` `            ``Console.WriteLine(``"No"``);` `    ``}` `}`   `// This code is contributed by vt_m.`

Output :

```No

```

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.