1
Flow of Control Part I
Department of Computer Science
APSC 160
Flow of Control Part II
Learning Goals
By the end of this section, you should be able to:
• read and write simple Boolean expressions
using relational operators
• read and write compound Boolean expressions
using the
and
,
or
and
not
operators
Boolean expressions
Boolean expressions
The following relational operators are used to construct Boolean
expressions:
<
less than
>
greater than
<=
less than or equal to
>=
greater than or equal to
!=
not equal to
==
equal to
Boolean expressions
Examples:
count < nChars
count % 2 == 0
count % 2 != 0
Compound Boolean expressions
The following
logical operators
that can be used to combine
Boolean expressions to form compound Boolean expressions:
&&
and
(binary operator)

o
(binary operator
or
(binary operator)
!
not
(unary operator)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document2
Compound Boolean expressions
The
and
operator – evaluates to true if and only if both the
operands evaluate to true:
p
q
p && q
true
true
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '10
 M.Smith
 Logic, relational operator, Unary operation, or operator

Click to edit the document details