islessgreater() in C/C++


islessgreater() 函式用於檢查第一個引數是否小於或大於第二個引數。在 C 語言中,它在“math.h”標頭檔案中宣告。如果成功則返回 true,否則返回 false。

以下是 C++ 語言中 islessgreater() 的語法:

bool islessgreater(value1 , value2);

其中,

value1 − 這是第一個引數,將與 value2 一起檢查。

value2 − 這是第二個引數,用於檢查 value1 並確定其是否較小或較大。

以下是在 C++ 語言中 islessgreater() 的示例:

示例

 線上演示

#include<iostream>
#include<math.h>
using namespace std;

int main() {
   int val1 = 28;
   int val2 = 8;
   
   bool result;
   result = islessgreater(val1, val2);
   cout << "val1 islessgreater than val2 : " << result << endl;

   return 0;
}

輸出

以下是輸出 −

val1 islessgreater than val2 : 1

在上面的示例中,比較了兩個值,其中一個比另一個小或大。它檢查 value1>value2 || value1<value2。如果其中一個( value1>value2 或 value1<value2 )為真,則返回 1。否則,將返回 0。

現在,讓我們看另一個當兩個值相等時的示例:

示例

 線上演示

#include<iostream>
#include<math.h>
using namespace std;

int main() {
   int val1 = 8;
   int val2 = 8;

   bool result;
   result = islessgreater(val1, val2);
   cout << "val1 islessgreater than val2 : " << result << endl;

   return 0;
}

輸出

以下是輸出 −

val1 islessgreater than val2 : 0

更新於: 25-Jun-2020

180 次瀏覽

開啟你的 職業生涯

完成課程認證

開始
廣告