islessgreater() in C/C++


The function islessgreater() is used to check that first argument is less than or greater than the second one. It is declared in “math.h” header file in C language. It returns true, if successful otherwise false.

Here is the syntax of islessgreater() in C++ language,

bool islessgreater(value1 , value2);

Here,

value1 − This is the first argument which will be checked with value2.

value2 − This is the second argument which is used to check value1 and see that is less or greater.

Here is an example of islessgreater() in C++ language,

Example

 Live Demo

#include<iostream>
#include<math.h>
using namespace std;

int main() {
   int val1 = 28;
   int val2 = 8;
   
   bool result;
   result = islessgreater(val1, val2);
   cout << "val1 islessgreater than val2 : " << result << endl;

   return 0;
}

Output

Here is the output −

val1 islessgreater than val2 : 1

In the above example, two values are compared and one of them is less or greater than the other. It checks value1>value2 || value1<value2. If one of them ( value1>value2 OR value1<value2 ) is true, it will return 1. Otherwise, it will return 0.

Now, let’s see another example when both values are equal,

Example

 Live Demo

#include<iostream>
#include<math.h>
using namespace std;

int main() {
   int val1 = 8;
   int val2 = 8;

   bool result;
   result = islessgreater(val1, val2);
   cout << "val1 islessgreater than val2 : " << result << endl;

   return 0;
}

Output

Here is the output −

val1 islessgreater than val2 : 0

Updated on: 25-Jun-2020

162 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements