Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.84 KB, 1 trang )
Chapter 4 Quick Reference
To Do this Example
Determine whether two values are
equivalent
Use the == or !=
operator.
answer == 42
Compare the value of two
expressions
Use the <, <=, >, or >=
operator.
age >= 21
Declare a Boolean variable
Use the bool keyword
as the type of the
variable.
bool inRange;
Create a Boolean expression that is
true only if two other conditions
are true
Use the && operator.
inRange = (lo <= number)
&& (number <= hi);
Create a Boolean expression that is
true if either of two other
conditions is true
Use the || operator.
outOfRange = (number < lo)
|| (hi < number);