ratio_not_equal() in C++ with examples
The ratio_not_equal is an inbuilt function in C++ STL that checks if two given ratios are not equal or equal.
Syntax:
template < class ratio1_name, class ratio2_name > ratio_not_equal
Template Parameters: The function accepts two template parameters ratio1 and ratio2 which are to be compared.
Return value: The function returns true if the ratios are not equal otherwise it returns false.
Program below demonstrates the function:
Program 1:
// C++ program to illustrate the // ratio_not_equal function #include <iostream> #include <ratio> using namespace std; int main() { typedef ratio<3, 9> ratio1; typedef ratio<1, 3> ratio2; // If both the ratios are not same if (ratio_not_equal<ratio1, ratio2>::value) cout << "Both ratio are not equal" ; else cout << "Both ratio are equal" ; return 0; } |
chevron_right
filter_none
Output:
Both ratio are equal
Program 2:
// C++ program to illustrate the // ratio_equal function #include <iostream> #include <ratio> using namespace std; int main() { typedef ratio<1, 2> ratio1; typedef ratio<5, 4> ratio2; // If both the ratios are not same if (ratio_not_equal<ratio1, ratio2>::value) cout << "Both ratio are not equal" ; else cout << "Both ratio are equal" ; return 0; } |
chevron_right
filter_none
Output:
Both ratio are not equal
Recommended Posts:
- C/C++ if statement with Examples
- C/C++ do while loop with Examples
- C/C++ if else if ladder with Examples
- C/C++ if else statement with Examples
- C/C++ while loop with Examples
- ios eof() function in C++ with Examples
- set_symmetric_difference in C++ with Examples
- SDL library in C/C++ with examples
- ratio_equal() in C++ with examples
- feclearexcept in C++ with Examples
- std::mismatch() with examples in C++
- C/C++ For loop with Examples
- Pointers in C/C++ with Examples
- mbrtoc32() in C/C++ with Examples
- mbrtoc16() in C/C++ with Examples
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.