Relational Operators in C Programming Language

Notes:

Relational Operators in C Programming Language:
Relational operators are also known as comparison operators. They are used find the relationship between two values or compare the relationship between two values; on comparison they yield the result either 0 or 1.

Note: 0 indicates FALSE and any non zero value indicates TRUE

< : less than
> : greater than

<= : less than or equal to
>= : greater than or equal to

== : equal to
!= : not equal to

Note: OR says if both LHS & RHS are 0 then the result will be 0; otherwise the result will be 1

LHS RHS LHS OR RHS
1 1 1
1 0 1
0 1 1
0 0 0

Example Code:

#include <stdio.h>

int main()
{
printf("%d\n",3<4); // 1
printf("%d\n",5<4); // 0

printf("%d\n",5>4); // 1
printf("%d\n",5>6); // 0

printf("%d\n",5<=6); // 1
printf("%d\n",6<=6); // 1
printf("%d\n",7<=6); // 0

printf("%d\n",7>=6); // 1
printf("%d\n",7>=7); // 1
printf("%d\n",7>=8); // 0

printf("%d\n",7==8); // 0
printf("%d\n",7!=8); // 1

return 0;
}