These are used for checking conditions. If at all
you want to work with more than one condition then make use of Logical operators.
Logical operators are
Logical and (&&)
Logical or (||)
Logical Not
(!)
Logical and needs minimum two conditions. Before the logical and one condition and
after the logical and one condition. If both the conditions are true the result
is true otherwise false. True means 1 false meas 0. Truth table for Logical and is
condition1
|
condition2
|
result
|
1
|
1
|
1
|
1
|
0
|
0
|
0
|
1
|
0
|
0
|
0
|
0
|
Write a program using Logical And (&&) operator
output
Logical Or(||)
Logical Or needs two conditions. Before the logical or one condition and after the logical or one condition. If both the conditions are false the result is false otherwise true. True means 1 false meas 0. Truth table for Logical or is
Logical Or needs two conditions. Before the logical or one condition and after the logical or one condition. If both the conditions are false the result is false otherwise true. True means 1 false meas 0. Truth table for Logical or is
condition
1
|
condition
2
|
result
|
1
|
1
|
1
|
1
|
0
|
1
|
0
|
1
|
1
|
0
|
0
|
0
|
Write a program using logical or(||) operator
Logical Not (!):-
Logical Not means opposite result. If the condition is true result is false. If the condition is false result is true.
Logical Not means opposite result. If the condition is true result is false. If the condition is false result is true.
Condition
|
Result
|
1
|
0
|
0
|
1
|
Write a program using logical not(!) operator









No comments:
Post a Comment