islessequal() in C/C++


The function islessequalr() is used to check that first argument is less than or equal to the second. It is declared in “math.h” header file. It returns true, if successful otherwise false.

Here is the syntax of islessequal()

bool islessequal(value1 , value2);

Here,

value1 − This is the first argument which will be checked with value2.

value2 − This is the second argument which is used to check value1 that is less or equal.

Here is an example of islessequal()

Example

 Live Demo

#include<iostream>
#include<math.h>
using namespace std;
int main() {
   int val1 = 8;
   int val2 = 8;
   bool result;
   result = islessequal(val1, val2);
   cout << "val1 islessequal than val2 : " << result << endl;
   return 0;
}

Output

val1 islessequal than val2 : 1

In the above example, two values are compared and one of them is less or equal to the other. It checks value1<value2 || value1=value2. If one of them ( value1<value2 OR value1=value2 ) is true, it will return 1. Otherwise, it will return 0.

Now, let’s see another example when value1 is greater than value2l,

Example

 Live Demo

#include<iostream>
#include<math.h>
using namespace std;
int main() {
   int val1 = 28;
   int val2 = 8;
   bool result;
   result = islessequal(val1, val2);
   cout << "val1 islessequal than val2 : " << result << endl;
   return 0;
}

Output

val1 islessequal than val2 : 0

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Jun-2020

133 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements