C++ program to find fourth side of a quadrilateral

Suppose we have three numbers a, b and c. We want to make a closed fence in a shape of arbitrary non-degenerate simple quadrilateral. We already have three sides of length a, b and c. We have to find another side d.

So, if the input is like a = 12; b = 34; c = 56, then the output will be 42, other answers are also possible.


To solve this, we will follow these steps −

return a + b + c - 2


Let us see the following implementation to get better understanding −

using namespace std;

int solve(int a, int b, int c){
   return a+b+c-2;
int main(){
   int a = 12;
   int b = 34;
   int c = 56;
   cout << solve(a, b, c) << endl;


12, 34, 56