Comparison Operators - C Operator

C examples for Operator:Relational Operator

Introduction

The comparison operators compare two values and return either true or false, represented as 1 or 0.

Demo Code

#include <stdio.h>
int main(void) {

    int x = (2 == 3); /* 0 - equal to */
    x = (2 != 3); /* 1 - not equal to */
    x = (2 > 3);  /* 0 - greater than */
    x = (2 < 3);  /* 1 - less than */
    x = (2 >= 3); /* 0 - greater than or equal to */
    x = (2 <= 3); /* 1 - less than or equal to */
}

Related Tutorials