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 (2.35 MB, 125 trang )
d. Vòng lặp
•
while
Câu lệnh while sẽ thực hiện các câu lệnh đến khi nào điều kiện đúng
while (điều kiện)
{
Mã thực thi
}
Ví dụ:
Explanation:
i equal to 0.
While i is less than , or equal to, 5, the loop will continue to run.
i will increase by 1 each time the loop runs.
Explanation:
i equal to 0.
The loop will run
i will increase by 1 each time the loop runs.
While i is less than , or equal to, 5, the loop will continue to run.
Explanation:
The for loop sets i equal to 0.
As long as i is less than , or equal to, 5, the loop will continue to run.
i will increase by 1 each time the loop runs.