ch 4 structure of algorithms

6
An Introduction to Programming Using Alice Boolean Logic

Upload: chaffey-college

Post on 15-Dec-2014

265 views

Category:

Documents


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Ch 4 structure of algorithms

An Introduction to Programming Using Alice

Boolean Logic

Page 2: Ch 4 structure of algorithms

An Introduction to Programming Using Alice

George Boole

In1854, George Boole published “An investigation into the Laws of Thought, on which are founded the Mathematical Theories of Logic and Probabilities.”

Boole outlined a system of logic and a corresponding algebraic language dealing with true and false values.

100th Anniverary Edition

Page 3: Ch 4 structure of algorithms

An Introduction to Programming Using Alice

Boolean Logic

Boolean logic is a form of mathematics in which the only values used are true and false.

Boolean logic is the basis of all modern computing.

There are three basic operations in Boolean logic – AND, OR, and NOT.

100th Anniverary Edition

Page 4: Ch 4 structure of algorithms

An Introduction to Programming Using Alice

The AND Operation

The AND operation is a binary operation, meaning that it needs two operands.

c = a AND b

Both a and b must be true for the result to be true.

100th Anniverary Edition

ANDa

T F

bT T F

F F F

Page 5: Ch 4 structure of algorithms

An Introduction to Programming Using Alice

The OR Operation

The OR operation is also a binary operation with two operands.

c = a OR b

If either a OR b is true, then the result is true.

100th Anniverary Edition

ORa

T F

BT T T

F T F

Page 6: Ch 4 structure of algorithms

An Introduction to Programming Using Alice

The NOT Operation

The NOT operation is a unary operation with only one operand.

c = NOT (a)

It simply reverses the true or false value of the operand.

100th Anniverary Edition

NOT

aT F

F T