C++ Standard Library C++ STL Library

C++ <cmath> - isgreater() Function



The C++ <cmath> isgreater() function returns true if the first argument is greater than the second argument, else returns false. If any of the arguments is NaN, the function returns false, and no FE_INVALID exception is raised but using > operator may raise such exception.

Syntax

bool isgreater (float x, float y);
bool isgreater (double x, double y);
bool isgreater (long double x, long double y);                  

Parameters

x Specify first value to be compared.
y Specify second value to be compared.

Return Value

Returns true (1) if the first argument is greater than the second argument, else returns false (0).

Example:

The example below shows the usage of isgreater() function.

#include <iostream>
#include <cmath>
using namespace std;
 
int main (){
  int x = 10;
  int y = 50;
  int z = 10;

  cout<<boolalpha;
  cout<<"x > y: "<<isgreater(x, y);
  cout<<endl;
  cout<<"x > z: "<<isgreater(x, z);
  cout<<endl;
  cout<<"y > z: "<<isgreater(y, z);

  return 0;
}

The output of the above code will be:

x > y: false
x > z: false
y > z: true

❮ C++ <cmath> Library