Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

Greater-than operator >

The > operator tests strict ordering. It returns int: 1 for true or 0 for false, including equality.

Version: C23; repository compiler flag, production runtime not attested

Syntax

left > right

left > right tests whether the left operand exceeds the right. Equality produces 0; >= also accepts equality.

Real-number operands undergo the usual arithmetic conversions. Mixing signed and unsigned types can change the expected result. Complex types are not permitted.

Do not chain a > b > c: it means (a > b) > c. Use a > b && b > c.

Pointers have separate rules: within one array, a later element has a greater pointer. Comparing pointers to unrelated objects with > has undefined behavior.

Examples

#include <stdio.h>

int main(void)
{
    int left = 8;
    int right = 5;

    printf("%d %d %d\n", left > right, right > left, left > left);
    return 0;
}

Result

1 0 0

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources