C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C++ Math islessequal()The islessequal() function checks whether the value of first argument is less than or equal to the second argument. If the value of first argument is less than or equal to the value of second argument, then it returns 1 otherwise 0. Note: If one or both the arguments are NAN then the function returns false(0).SyntaxConsider two numbers 'x' and 'y'. Syntax would be: bool islessequal(float x,float y); bool islessequal(double x,double y); bool islessequal(long double x,long double y); bool islessequal(Arithmetic x,Arithmetic y); Parameter(x,y): The values which we want to compare. Return value
Example 1Let's see a simple example when both x and y are of same type. #include <iostream> #include<math.h> using namespace std; int main() { float x= 3.4; float y=3.4; cout<<"Values of x and y are : "<<x<<","<<y<<'\n'; cout<<"islessequal(x,y) : "<<islessequal(x,y); return 0; } Output: Values of x and y are : 3.4,3.4 islessequal(x,y) : 1 In this example, islessequal() function determines that both x and y are equal. Therefore, it returns 1. Example 2Let's see a simple example when both x and y are of different type. #include <iostream> #include<math.h> using namespace std; int main() { float x= 7.8; int y=2; cout<<"Values of x and y are : "<<x<<","<<y<<'\n'; cout<<"islessequal(x,y) : "<<islessequal(x,y); return 0; } Output: Values of x and y are : 7.8,2 islessequal(x,y) : 0 In this example, x is greater than y. Therefore, the function returns 0. Example 2Let's see a simple example . #include <iostream> #include<math.h> using namespace std; int main() { float x= 0.0/0.0; float y=0.0/0.0; cout<<"Values of x and y are : "<<x<<","<<y<<'\n'; cout<<"islessequal(x,y) : "<<islessequal(x,y); return 0; } Output: Values of x and y are : nan,nan islessequal(x,y) : 0 In this example, both x and y are NAN. Therefore, the function returns 0.
Next TopicC++ Math Functions
|