Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> การเขียนโปรแกรม C

isgreaterequal() ใน C/C++

isgreaterequal() ตรวจสอบว่า argument แรก >= argument ที่สอง ประกาศใน math.h คืนค่า true (1) ถ้าจริง false (0) ถ้าเท็จ

ไวยากรณ์

bool isgreaterequal(value1, value2);

ตัวอย่างที่ 1 (true)

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

ผลลัพธ์

val1 isgreaterequal than val2: 1

ตัวอย่างที่ 2 (false)

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

ผลลัพธ์

val1 isgreaterequal than val2: 0