isgreaterequal() in C/C++
In C++, isgreaterequal() is a predefined function used for mathematical calculations. math.h is the header file required for various mathematical functions. isgreaterequal() function used to check whether the 1st argument given to the function is greater than or equal to the 2nd argument given to the function or not. Means if a is the 1st argument and b is the 2nd argument then it check whether a>=b or not. Syntax:
bool isgreaterequal(a, b)
- If a or b or both is NaN then the function raised an exception and return false(0).
Time Complexity: O(1)
Auxiliary Space: O(1)
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
float a = 5.5;
double f1 = nan( "1" );
bool result;
result = isgreaterequal(a, f1);
cout << a << " isgreaterequal " << f1
<< ": " << result;
return 0;
}
|
5.5 isgreaterequal nan: 0
Program 1:
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
int a, b;
bool result;
a = 5;
b = 8;
result = isgreaterequal(a, b);
cout << a << " isgreaterequal to " << b
<< ": " << result << endl;
a = 8;
b = 5;
result = isgreaterequal(a, b);
cout << a << " isgreaterequal to " << b
<< ": " << result;
return 0;
}
|
5 isgreaterequal to 8: 0
8 isgreaterequal to 5: 1
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
bool result;
float a = 80.23;
int b = 82;
result = isgreaterequal(a, b);
cout << a << " isgreaterequal to " << b
<< ": " << result << endl;
char x = 'b' ;
result = isgreaterequal(x, a);
cout << x << " isgreaterequal to " << a
<< ": " << result;
return 0;
}
|
80.23 isgreaterequal to 82: 0
b isgreaterequal to 80.23: 1
Application
There are variety of applications where we can use isgreaterequal() function to compare two values like to use in for loop to print table of any number say 12.
CPP
#include <bits/stdc++.h>
using namespace std;
int main()
{
for ( int i = 1;
isgreaterequal(10, i);
i++) {
cout << "12 x " << i << " = "
<< 12 * i << endl;
}
return 0;
}
|
Output:
12 x 1 = 12
12 x 2 = 24
12 x 3 = 36
12 x 4 = 48
12 x 5 = 60
12 x 6 = 72
12 x 7 = 84
12 x 8 = 96
12 x 9 = 108
12 x 10 = 120
Last Updated :
20 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...