isgreater() in C/C++ Last Updated : 14 Mar, 2023 Comments Improve Suggest changes Like Article Like Report In C++, isgreater() is a predefined function used for mathematical calculations. math.h is the header file required for various mathematical functions.isgreater() function used to check whether the 1st argument given to the function is greater than 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 isgreater(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 error occurs with this function. Exception: 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 // CPP code to illustrate // the exception of function #include <bits/stdc++.h> using namespace std; int main() { // Take any values int a = 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 = isgreater(f1, a); cout << f1 << " isgreater than " << a << ": " << result; return 0; } Output: nan isgreater than 5: 0 Program: CPP // CPP code to illustrate // the use of isgreater function #include <bits/stdc++.h> using namespace std; int main() { // Take two any values int a, b; bool result; a = 5; b = 8; // Since 'a' is not greater // than 'b' so answer // is false(0) result = isgreater(a, b); cout << a << " isgreater than " << b << ": " << result << endl; char x = 'd'; // Since 'd' ascii value is greater // than b variable so answer // is true(1) result = isgreater(x, b); cout << x << " isgreater than " << b << ": " << result; return 0; } Output: 5 isgreater than 8: 0 d isgreater than 8: 1 This function can be used in any comparison based sorting algorithm. Let's use it in bubble sort: CPP // CPP code to illustrate the // use of isgreaterequal function #include <bits/stdc++.h> using namespace std; int main() { // taking inputs int arr[] = { 5, 2, 8, 3, 4 }; int n = sizeof(arr) / sizeof(arr[0]); for (int i = 0; i < n - 1; i++) { for (int j = 0; j < n - i - 1; j++) { if (isgreater(arr[j], arr[j + 1])) { int k = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = k; } } } cout << "Sorted array: "; for (int i = 0; i < n; i++) { cout << arr[i] << ", "; } return 0; } Output: Sorted array: 2, 3, 4, 5, 8, Comment More infoAdvertise with us Next Article isgreater() in C/C++ A AKASH GUPTA 6 Follow Improve Article Tags : Misc C Language C++ CPP-Library C-Library cpp-math +2 More Practice Tags : CPPMisc Similar Reads islessgreater() in C/C++ In C++, islessgreater() is a predefined function used for mathematical calculations. math.h is the header file required for various mathematical functions.islessgreater() function is used to check whether the 1st argument given to the function is less than or greater than the 2nd argument given to t 3 min read 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 th 3 min read isless() in C/C++ In C++, isless() is a predefined function used for mathematical calculations. math.h is the header file required for various mathematical functions.isless() function used to check whether the 1st argument given to the function is less than the 2nd argument given to the function or not. Means if a is 2 min read isdigit() in C++ The isdigit() function in C++ checks whether a given character is a digit or not. Let's take a look at an example:C++#include <bits/stdc++.h> using namespace std; int main() { char c = '5'; if (isdigit(c)) cout << c << " is a Digit"; else cout << c << " is not a Digit"; 3 min read dot (.) Operator in C In C, the dot (.) operator is used to access members of user defined data types such as a structure or union. Also known as the direct member access operator, it allows us to access the data of the struct and union via the name of variables.Let's take a look at an example:C#include <stdio.h> s 2 min read Like