C++ Math islessgreater()

The islessgreater() fuinction determines whether the value of first argument is less than or greater than the value of second argument. If the value of first argument is less than or greater than the second argument then it returns 1 otherwise 0.

Note: If one or both the arguments are NAN, then the function returns false(0).

Syntax

Consider two numbers 'x' and 'y'. Syntax would be:

Parameter

(x,y): The values which we want to compare.

Return value

ParameterReturn value
x>y or x1
x=y or x=nan or y=nan0

Example 1

Let's see a simple example when both x and y are equal.

Output:

Values of x and y are : 1.2,1.2
islessgreater(x,y) : 0

In this example, the values of both x and y are equal. Therefore, the function returns 0.

Example 2

Let's see a simple example when both x and y are of different type and are unequal.

Output:

Values of x and y are : 7,3.2
islessgreater(x,y) : 1

In this example, value of x is greater than the value of y. Therefore, the function returns 1.

Example 3

Let's see a simple example when the value of x is NAN.

Output:

Values of x and y are : nan,3.2
islessgreater(x,y) : 0

In this example, value of x is NAN. Therefore, the function returns 0.






Latest Courses