Comparison Operators in C Language:
(1) Comparison Operators are used for comparing two variables.
(2) Sample C language code and its output, as shown:
#include <stdio.h> #include <conio.h> // Assignment Operators in C Language int main() { int x; int y; x = 5; y = 5; printf(“x equals to y: %d\n”, x == y); x = 5; y = 6; printf(“x not equals to y: %d\n”, x != y); x = 7; y = 6; printf(“x greater than y: %d\n”, x > y); x = 5; y = 6; printf(“x lesserthan y: %d\n”,x< y); x = 7; y = 6; printf(“x greater than or equals to y: %d\n”, x >= y); x = 5; y = 6; printf(“x less than or equals to y: %d\n”, x <= y); getch(); return 0; } |
(3) After that go to the “Build” menu and select the “Build” option for publishing the code as shown.
(4) After building the code, press the “Run” button, as shown.
(5) After pressing the “run” button, the output screen is opened, as shown.
Comparison Operators | Description |
---|---|
== | Equal to |
!= | Not Equal to |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |