In C++, the islessgreater() function is defined in the <cmath> or <math.h> header file and is used to determine whether the first argument is either less than or greater than the second argument. In other words, it checks whether the two values are unequal. If the values are unequal, the function returns 1; otherwise, it returns 0.
The islessgreater() function supports float, double, long double, and other arithmetic data types.
It has the following syntax.
(x,y): The values which we want to compare.
| Parameter | Return value |
|---|---|
| x>y or x | 1 |
| x=y or x=nan or y=nan | 0 |
Here, we are going to discuss several examples to demonstrate the islessgreater() Function.
This example demonstrates how the islessgreater() function behaves when both values are equal.
Output:
Values of x and y are : 1.2,1.2 islessgreater(x,y) : 0
Explanation:
In this example, the values of both x and y are equal. Therefore, the function returns 0.
This example demonstrates how the islessgreater() function behaves when the values are unequal and of different data types.
Output:
Values of x and y are : 7,3.2 islessgreater(x,y) : 1
Explanation:
In this example, value of x is greater than the value of y. Therefore, the function returns 1.
This example demonstrates how the islessgreater() function behaves when one of the values is NaN (Not a Number).
Output:
Values of x and y are : nan,3.2 islessgreater(x,y) : 0
Explanation:
In this example, value of x is NAN. Therefore, the function returns 0.
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India