DO NOT MISS

Ads

Friday, 17 June 2016

Logical Operators in C-Language

Logical Operators:-
These are used to we want to test more than one condition & make decisions an exp of this kind which combines two or more relational exp’s is turned as a logical exp.


Logical operators are
Logical operators
Operator
Meaning
&&
Logical AND
||
             Logical OR
!
Logical NOT

These are used to perform logical operations.
1 is True, 0 is False.

Logical AND:-
If both the operands are Non-zero, then condition is true.
Ex:-
a=1, b=1  (a&&b) - Condition is true
a=1, b=0 (a&&b) - Condition is false

It is used in the fallowing form
Expression 1 && Expression 2
Logical AND
Expression 1
Operator
Expression 2
Result
T
&&
T
T
T
&&
F
F
F
&&
T
F
F
&&
F
F

Logical OR:-
If any of the two operands is Non-zero. Then Condition becomes true. 
Ex:-
a=1, b=0  (a||b) - condition is true
a=0, b=0 (a||b) - condition is false

It is used in the fallowing form
Expression 1 || Expression 2
Logical OR
Expression 1
Operator
Expression 2
Result
T
||
T
T
T
||
F
T
F
||
T
T
F
||
F
F

Logical NOT:-
It is used to reverse the logical statement of its operand.
Ex:-
a=1, b=0  (a&&b) Condition is false
a=1, b=0 !(a&&b) Condition is true

It is used in the fallowing form
Not Expression = !(Expression)
Logical NOT
Operator
Expression
Result
!
T
F
!
F
T

Greataims

 
Copyright © 2016 Computersadda. Designed by @ Computersadda Team - Published By Greataims