# 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)
```

Parameters:

• a, b => These two are the parameters whose value we want to compare.
• Result:

• The function will return the true if a>=b else it returns false.
• Error:

• No particular error occurs with this function.

Exceptions associated with this function:

• If a or b or both is NaN then the function raised an exception and return false(0).

 `// CPP code to illustrate ` `// the exception of function ` `#include ` `using` `namespace` `std; ` ` `  `int` `main() ` `{ ` `    ``// Take any values ` `    ``float` `a = 5.5; ` `    ``double` `f1 = nan(``"1"``); ` `    ``bool` `result; ` ` `  `    ``// Since f1 value is NaN so ` `    ``// with any value of a, the function ` `    ``// always return false(0) ` `    ``result = isgreaterequal(a, f1); ` `    ``cout << a << ``" isgreaterequal "` `<< f1 ` `         ``<< ``": "` `<< result; ` ` `  `    ``return` `0; ` `} `

Output:

```5.5 isgreaterequal nan: 0
```

Examples:

• Program 1:

 `// CPP code to illustrate ` `// the use of isgreaterequal function ` `#include ` `using` `namespace` `std; ` ` `  `int` `main() ` `{ ` `    ``// Take two any values ` `    ``int` `a, b; ` `    ``bool` `result; ` `    ``a = 5; ` `    ``b = 8; ` ` `  `    ``// Since 'a' is not greater ` `    ``// than equal to 'b' so answer ` `    ``// is false(0) ` `    ``result = isgreaterequal(a, b); ` `    ``cout << a << ``" isgreaterequal to "` `<< b ` `         ``<< ``": "` `<< result << endl; ` ` `  `    ``a = 8; ` `    ``b = 5; ` ` `  `    ``// Since 'a' is greater ` `    ``// than 'b' so answer ` `    ``// is true(1) ` `    ``result = isgreaterequal(a, b); ` `    ``cout << a << ``" isgreaterequal to "` `<< b ` `         ``<< ``": "` `<< result; ` ` `  `    ``return` `0; ` `} `

Output:

```5 isgreaterequal to 8: 0
8 isgreaterequal to 5: 1
```
• Note: Using this function you can compare any data type with any other data type as well.

• Program 2:

 `// CPP code to illustrate ` `// the use of isgreaterequal function ` `#include ` `using` `namespace` `std; ` ` `  `int` `main() ` `{ ` `    ``// Take two any values ` `    ``bool` `result; ` `    ``float` `a = 80.23; ` `    ``int` `b = 82; ` ` `  `    ``// Since 'a' is not greater ` `    ``// than equal to 'b' so answer ` `    ``// is false(0) ` `    ``result = isgreaterequal(a, b); ` `    ``cout << a << ``" isgreaterequal to "` `<< b ` `         ``<< ``": "` `<< result << endl; ` ` `  `    ``char` `x = ``'b'``; ` ` `  `    ``// Since 'b' ascii value is greater ` `    ``// than variable a so answer ` `    ``// is true(1) ` `    ``result = isgreaterequal(x, a); ` `    ``cout << x << ``" isgreaterequal to "` `<< a ` `         ``<< ``": "` `<< result; ` ` `  `    ``return` `0; ` `} `

Output:

```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 code to illustrate ` `// the use of isgreaterequal function ` `#include ` `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
```

My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.