![]() |
In 1854 he published An investigation into the Laws of Thought, on Which are founded the Mathematical Theories of Logic andProbabilities Boole approached logic in a new way reducing it to a simple algebra, incorporating logic into mathematics. He pointed out the analogy between algebraic symbols and those that represent logical forms. It began the algebra of logic called Boolean Algebra which now finds application in computer construction, switching circuits etc. |
bool a = true;
bool b = 5; // number not equal to 0 means true
bool c = 0; // falsetrue or false0 means false,
any other number means truecout of a bool is 0 (if
the bool is false) or 1 (if
the bool is true).| C++ notation |
English |
Sample |
|---|---|---|
== |
equal to |
x+7==2*y |
!= |
not equal to |
ans != 'n' |
< |
less than |
count < 1000 |
<= |
less than or equal to |
time <= limit |
> |
greater than |
time > limit |
>= |
greater or equal than |
age >= 21 |
| C++ notation |
English |
Sample |
|---|---|---|
&& |
and |
(income > 20000) && (income
< 30000) |
|| |
or |
(grade=='A') || (grade=='B') |
! |
not |
!(age < 21) |
&& and ||examples
are not necessary1? int a = ????;
cout << (a > 1 && a < 10 && a%2==1);a = 3, what is !(a > 5 || a <7)?| Syntax |
Meaning |
Example |
|---|---|---|
if(condition) |
if condition is true, execute the statement. |
char gender; |
if(condition) { |
if condition is true, execute the statements. | if(myScore
> yourScore) {cout << "I win!\n";
|
/* |
| Syntax |
Meaning |
Example |
|---|---|---|
if(condition) |
If condition is true, execute yes_statement. If condition is false, execute no_statement. |
char gender; |
if(condition) { |
If condition is true, execute yes_statements. If condition is false, execute no_statemenst. |
if(myScore
> yourScore) {cout << "I win!\n";
|
| Syntax |
Meaning |
|---|---|
if(condition1) { |
If condition1 is true, execute statement1. If condition2 is true, execute statement2. .......... if none of the above conditions is true, execute statment_for_other |
/**/ |