|
Compare operations | Meaning
---------------------+-----------------------------------------------------
x == y | returns 1 if x is equals to y, returns 0 otherwise
x != y | returns 1 if x is not equals to y, returns 0 otherwise
x < y | Ditto: less than
x <= y | Ditto: less than or equal
x > y | Ditto: greater than
x >= y | Ditto: greater than or equal
|
|
Compare operations | Meaning
---------------------+-----------------------------------------------------
x && y | returns 1 if "x and y" is true, returns 0 otherwise
x || y | Ditto: logical or
!x | Ditto: logical not
|
#include <stdio.h>
int main( int argc, char* argv[] )
{
printf("4 == 3 = %d\n", (4==3) );
printf("4 > 3 = %d\n", (4 > 3) );
printf("4 && 3 = %d\n", (4 && 3) );
printf("4 && 0 = %d\n", (4 && 0) );
printf("4 || 0 = %d\n", (4 || 0) );
printf("0 || 0 = %d\n", (0 || 0) );
}
|
Output:
4 == 3 = 0 4 > 3 = 1 4 && 3 = 1 4 && 0 = 0 4 || 0 = 1 0 || 0 = 0 |
How to run the program:
|
|