Nesbitt’s Inequality in C++


The nesbitt's inequality is (a/(b + c)) + (b/(c + a)) + (c/(a + b))>= 1.5, a > 0, b > 0, c > 0

Given three number, we need to check whether the three numbers satisfy Nesbitt's inequality or not.

We can test whether three number are satisfied nesbitt's inequality or not. It's a straightforward program.

Algorithm

  • Initialise three numbers a, b, and c.
  • Compute the values of each part from the equation.
  • Add them all.
  • If the total sum is greater than or equal to 1.5 then it satisfies the Nesbitt's inequality else it is not satisfied.

Implementation

Following is the implementation of the above algorithm in C++

#include <bits/stdc++.h>
using namespace std;
bool isValidNesbitt(double a, double b, double c) {
   double A = a / (b + c);
   double B = b / (a + c);
   double C = c / (a + b);
   double result = A + B + C;
      return result >= 1.5;
}
int main() {
   double a = 3.0, b = 4.0, c = 5.0;
   if (isValidNesbitt(a, b, c)) {
      cout << "Nesbitt's inequality is satisfied" << endl;
   }else {
      cout << "Nesbitt's inequality is not satisfied" << endl;
   }
return 0;
}

Output

If you run the above code, then you will get the following result.

Nesbitt's inequality is satisfied

Updated on: 23-Oct-2021

155 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements