- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
Advertisements