Logical Operators in C Language:
(1) Logical Operators are used for assigning values to variables.
(2) Sample C language code and its output, as shown:

#include <stdio.h> #include <conio.h> // Logical Operators in C Language intmain() { int x; int y; x = 5; y = 7; // Returns 1 printf(“Return Value: %d\n”, x > 3 && x < 10); // Returns 0 printf(“Return Value: %d\n”, x > 3 && x < 5); x = 5; y = 2; //Returns 1 printf(“Return Value: %d\n”, x > 3 || x < 7); //Returns 0 printf(“Return Value: %d\n”, y > 4 || x < 1); x = 5; y = 11; // Returns 0 printf(“Return Value: %d\n”, !(x > 3 && x < 10)); // Returns 1 printf(“Return Value: %d\n”, !(y > 3 && y < 10)); 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.

Logical Operators | Operations |
---|---|
&& | Logical AND operator |
|| | Logical OR Operator |
! | Logical NOT Operator |