The logical operator is a valid combination of logical values, variables and operators. The logical values can be combined with relational operators.
Note : The logical operators also written either ONE or ZERO.
Logical NOT( ! )
Logical AND ( && )
Logical OR ( || )
EXAMPLES :
NOT :-
OR :-
main( )
output :
0 ( According to AND operator before condition is dissatisfies, it does not check the remaining expression )
Note : The logical operators also written either ONE or ZERO.
Logical NOT( ! )
A
|
R
|
0
|
1
|
1
|
0
|
A
|
B
|
R
|
0
|
0
|
0
|
0
|
1
|
0
|
1
|
0
|
0
|
1
|
1
|
1
|
A
|
B
|
R
|
0
|
0
|
0
|
0
|
1
|
1
|
1
|
0
|
1
|
1
|
1
|
1
|
a = !1 ===> 0
a = !0 ===> 1
main( )
{
int a;
a=5>4 | | 7>9;
printf("%d",a);
getch( );
}
output :
1 ( According to OR operator before condition is satisfies, it does not check the remaining expression )
1 ( According to OR operator before condition is satisfies, it does not check the remaining expression )
AND :-
{
int a;
a=5>9 && 7>2;
printf("%d",a);
getch( );
}
0 ( According to AND operator before condition is dissatisfies, it does not check the remaining expression )