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.

Steps

To solve this, we will follow these steps −

return a + b + c - 2

Example

Let us see the following implementation to get better understanding −

#include<bits/stdc++.h>
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;
}

Input

12, 34, 56

Output

100

Updated on: 03-Mar-2022

160 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements