Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

Less-than-or-equal operator (<=)

The <= operator tests whether the left operand is less than or equal to the right operand. Its result is an int: either 1 or 0.

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

Syntax

left <= right

left <= right produces 1 when the left operand is less than or equal to the right operand, and 0 otherwise. The result has type int, not bool.

Numeric operands must have real types; the usual arithmetic conversions apply. Mixing signed and unsigned types can change the expected result.

Comparisons associate left to right: a <= b <= c means (a <= b) <= c. Write a range check as a <= b && b <= c.

Examples

#include <stdio.h>

int main(void)
{
    int value = 10;
    int limit = 10;

    printf("%d %d\n", value <= limit, (value + 1) <= limit);
    return 0;
}

Result

1 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