Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • Alteryx
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Go Programs
    • Python Programs
    • Java Programs

Logical Operators in C

by suresh

The Logical operators in C are some of the Operators, which are used to combine two or more conditions. And perform the logical operations using && (Logical AND), || (Logical OR) and ! (Logical NOT)

The Relational Operators in C are used to compare two variables, what if we want to compare more than one condition? Very simple, C logical operators will do the trick for you.

The below table shows all the list of Logical Operators in C with examples.

OPERATORSNAMEDESCRIPTIONEXAMPLE
&&logical ANDIt returns true when both conditions are trueIf (age > 18 && age <=35)
||logical ORIt returns true when at-least one of the condition is trueIf (age > 35 || age < 60)
!logical NOTIf the condition is true, logical NOT operator makes it falseIf age = 18 then!( age = 18) returns false.

Let us see the truth tables behind the logical operators in C Programming for better understanding of Operators.

&& LOGICAL AND Operator

Condition 1Condition 2Condition 1 && Condition 2
TrueTrueTrue
TrueFalseFalse
FalseTrueFalse
FalseFalseFalse

|| (LOGICAL OR Operator)

Condition 1Condition 2Condition 1 || Condition 2
TrueTrueTrue
TrueFalseTrue
FalseTrueTrue
FalseFalseFalse

Placed Under: C Programming

  • C Comments
  • C Escape Sequence
  • C Programming Operators
  • C Arithmetic Operators
  • C Assignment Operators
  • C Bitwise Operators
  • C Conditional Operator
  • C Increment & Decrement Optr
  • C Logical Operators
  • C Relational Operators
  • C Sizeof Operator
  • C If Statement
  • C IF ELSE Statement
  • C Else If Statement
  • C Nested If
  • C Break Statement
  • C Continue Statement
  • C Goto Statement
  • C Switch Case
  • C For Loop
  • C While Loop
  • C Do While Loop
  • C Arrays
  • C Two Dimensional Array
  • C Multi Dimensional Array
  • C String
  • C Structures
  • C Nested Structures
  • C Array of Structures
  • C Structures and Functions
  • C Union
  • C Structure & Union differences
  • C Pointers
  • C Pass Pointers to Functions
  • C GETS
  • C fgets Function
  • C fgetc
  • C fputs function
  • C fputc
  • C Functions
  • C Types of Functions
  • C Pass Array to Functions
  • Call By Value & Call By Reference
  • C Recursion
  • C Program Examples

Copyright © 2021 · All Rights Reserved by Suresh

About Us | Contact Us | Privacy Policy