1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Chapter 4 Quick Reference ppt

1 268 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 6,84 KB

Nội dung

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); Run a statement if a condition is true Use an if statement. if (inRange) process(); Run more than one statement if a condition is true Use a block. if (seconds == 59) { seconds = 0; minutes++; } Associate different statements with different values of a controlling expression Use a switch statement. switch (current) { case '<': break; default : break; } . Chapter 4 Quick Reference To Do this Example Determine whether two values are equivalent Use the == or != operator. answer == 42 Compare

Ngày đăng: 21/01/2014, 15:20