For some people it may be difficult to understand what Boolean is.Well, it's a type of algebra.
We will be learning about three Boolean operators today-AND,OR,NOT
The order for evaluating Boolean operators are as follows:-
AND-If you have a code that should be executed if two conditions are true, you use the and operator.And is shown as && in C++.1 && 0 will evaluate to 0 because one of them is false.
OR-Same as and, but either or both of the conditions must be true.Or is shown as || in C++.1 || 0 will evaluate to 1 since one of them is true.
NOT-Exactly reverses a statement.It is shown as ! in C++.!(1 && 0) will evaluate to 1.Why you ask?1 && 0 evaluates to 0 and !0 (reversed) will become 1.
Now lets try out a complicated Boolean statement-
!( (1 || 0) && 0 )ANSWER=1.(Brackets are always first)
1 || 0 = 1
1 && 0 = 0
!0 (reversed) = 1
Finally,why are Boolean operators used?Well,to make more complex conditional statements.Suppose you want a number to be less than 10 and more than 5 you use &&.
Thanks for checking out this tutorial,