在 C/C++ 中使用 isgreater()
isgreater() 函式用來檢查第一個引數是否大於第二個引數。它在 C 語言的“math.h”標頭檔案中宣告。如果成功,它返回真,否則返回假。
以下是 isgreater() 的語法。
bool isgreater(value1 , value2);
其中,
value1 - 這是將與 value2 進行比較的第一個引數。
value2 - 這是用於檢查 value1 是否更大的第二個引數。
下面是一個 isgreater() 函式的示例。
示例
#include<iostream> #include<math.h> using namespace std; int main() { int val1 = 28; int val2 = 8; bool result; result = isgreater(val1, val2); cout << "val1 is greater than val2 : " << result << endl; return 0; }
輸出
val1 is greater than val2 : 1
在上述程式中,isgreater() 函式的功能存在於 main() 函式中。宣告三個變數:val1、val2 和 result。該函式檢查第一個值 val1 是否大於第二個值 val2。結果儲存在變數 result 中。
result = isgreater(val1, val2);
廣告