TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

C++ Math islessgreater() Function

C++ Math islessgreater() Function with tutorial for beginners and professionals with examples on isgreaterequal(), less(), islessequal(), islessgreater(), isunordered(), exp(), frexp(), ldexp(), log(), log10(), modf(), exp2(), expm1(), log1p(), log2(), logb(), scalbn(), scalbln() etc.

<< Back to CPP

C++ Math islessgreater()

The islessgreater() fuinction determines whether the value of first argument is less than or greater than the value of second argument. If the value of first argument is less than or greater than the second argument then it returns 1 otherwise 0.

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

Syntax

Consider two numbers 'x' and 'y'. Syntax would be:

bool islessgreater(float x, float y);
bool islessgreater(double x, double y);
bool islessgreater(long double x, long double y);
bool islessgreater(Arithmetic x, Arithmetic y);

Parameter

(x,y): The values which we want to compare.

Return value

Parameter Return value
x>y or x 1
x=y or x=nan or y=nan 0

Example 1

Let's see a simple example when both x and y are equal.

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  float x=1.2;
  float y=1.2;
  cout<<"Values of x and y are : "<<x<<","<<y<<'\n';
  cout<<"islessgreater(x,y) : "<<islessgreater(x,y);
  return 0;
}

Output:

Values of x and y are : 1.2,1.2
islessgreater(x,y) : 0

In this example, the values of both x and y are equal. Therefore, the function returns 0.

Example 2

Let's see a simple example when both x and y are of different type and are unequal.

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  int x=7;
  float y=3.2;
  cout<<"Values of x and y are : "<<x<<","<<y<<'\n';
  cout<<"islessgreater(x,y) : "<<islessgreater(x,y);
  return 0;
}

Output:

Values of x and y are : 7,3.2
islessgreater(x,y) : 1

In this example, value of x is greater than the value of y. Therefore, the function returns 1.

Example 3

Let's see a simple example when the value of x is NAN.

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  float x=0.0/0.0;
  float y=3.2;
  cout<<"Values of x and y are : "<<x<<","<<y<<'\n';
  cout<<"islessgreater(x,y) : "<<islessgreater(x,y);
  return 0;
}

Output:

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

In this example, value of x is NAN. Therefore, the function returns 0.


Next TopicC++ Math Functions




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf