Logical Operators in C

In this tutorial, you will learn about the Logical operations in C and their usage and examples.

Logical Operations in C with Examples

The table below illustrates the Logical Operators in C, a brief description, and simple examples.

&& (logical AND)It returns true if both conditions are true(x>5)&&(y<5)
|| (logical OR)It returns true if at-least one of the condition is true(x>=10)||(y>=10)
! (logical NOT)It reverses the state of the operand “((x>5) && (y<5))”!((x>5)&&(y<5))

Example of Logical Operators in C

#include <stdio.h>

main() {

   int x = 5;
   int y = 10;
   int z ;

   if ( x && y ) {
      printf("x && y is true\n" );

   if ( x || y ) {
      printf("x || y is true\n" );



x && y is true
x || y is true


Back to: Learn C Programming > Expression and Operators in C

Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.