Math Islessequal Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Islessequal Function

Math Islessequal Function

BLUF: Mastering Math Islessequal Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Islessequal Function

C++ is renowned for its efficiency. Learn how Math Islessequal Function enables low-level control and high-performance computing in the tutorial below.

C++ Math islessequal

The islessequal function verifies if the value of the initial argument is less than or equal to the second argument. It returns 1 if the value of the first argument is less than or equal to the value of the second argument; otherwise, it returns 0.

Note: If one or both the arguments are NAN then the function returns false(0).

Syntax

Consider two variables 'x' and 'y'. The syntax should be as follows:

Example

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

Parameter(x,y) Return value
x_PRESERVE7__y or x=nan or y=nan 0

Example 1

Let's consider a straightforward scenario where both variables x and y are of identical data type.

Example

#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:

Output

Values of x and y are : 3.4,3.4
islessequal(x,y) : 1

In this instance, the islessequal function establishes that x and y are equal, resulting in a return value of 1.

Example 2

Let's examine a basic scenario where both variables x and y are of distinct data types.

Example

#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:

Output

Values of x and y are : 7.8,2
 islessequal(x,y) : 0

In this instance, the value of x surpasses y. As a result, the function will output 0.

Example 2

Let's see a simple example .

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:

Output

Values of x and y are : nan,nan
islessequal(x,y) : 0

In this instance, both x and y are NaN. As a result, the function will output a value of 0.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience