C Logical operator
C Logical operator
3. Logical Operator in C
Logical Operators are used to combine two or more
conditions/constraints or to complement the evaluation of the original
condition in consideration. The result of the operation of a logical
operator is a Boolean value either true or false.
1 Returns true if
both the
&& Logical AND a && b
operands are
true.
2 Returns true if
|| both or any of a || b
Logical OR
the operand is
true.
3 Returns true if
! Logical NOT the operand is !a
false.
https://www.geeksforgeeks.org/operators-in-c/ 7/27
1/26/25, 6:19 PM Operators in C - GeeksforGeeks
return 0;
15 }
Output
a && b : 1
a || b : 1
!a: 0
4. Bitwise Operators in C
The Bitwise operators are used to perform bit-level operations on the
operands. The operators are first converted to bit-level and then the
calculation is performed on the operands. Mathematical operations such
as addition, subtraction, multiplication, etc. can be performed at the bit
level for faster processing.
1 Performs bit-
by-bit AND
& Bitwise AND operation and a&b
returns the
result.
2 Performs bit-
by-bit OR
| Bitwise OR operation and a|b
returns the
result.
3 Performs bit-
by-bit XOR
^ Bitwise XOR operation and a^b
returns the
result.
https://www.geeksforgeeks.org/operators-in-c/ 8/27