Professional Documents
Culture Documents
Lecture 8
Introduction
• A conditional expression is also referred to as a test condition. To
determine, for example, who receives an A on an exam, a relational
test is made between two operands.
• The first operand is an exam score, and the second is a value such as
90, or some predetermined cutoff value for an A.
• The result will be false. With expressions involving ||, if the first
evaluates as true, there is no need to evaluate the second.
• Adding the NOT operator ! negates that result. Thus, the expression
evaluates to false.
Consider this Example for && and ||
Boolean Operator
• A variable declared to be of bool type holds the value of true or false.
• Boolean data types are often used as flags to signal when a condition exists
or when a condition changes.
• As long as the value of the Boolean variable remains the same, processing
continues. When some planned condition changes, the Boolean data type
is changed and processing stops.