TAILIEUCHUNG - Computer Programming for Teens phần 5

Những giá trị này không phải là các dây đúng hay sai. Họ là những giá trị đúng hay sai. Cách duy nhất để có được các giá trị này là sử dụng các nhà khai thác quan hệ (, vv) và / hoặc người điều khiển logic (và, hoặc không) từ Chương 3. Khi bạn so sánh hai con số với một nhà điều hành quan hệ, | The Conditional Loop 121 10 is even 11 is odd. 12 is even 13 is odd. 14 is even 15 is odd. 16 is even 17 is odd. 18 is even 19 is odd. You will not see 20 on the screen because the loop is exited before 20 is used in the body of the loop. Recall that the boolean condition was x 20. Once x hits 20 or becomes 20 the boolean expression becomes false and the loop is exited. On the CD The complete program that prints even or odd next to a list of numbers. The Conditional Loop A conditional loop is a loop that does not spin a fixed number of times. It spins only on the condition that some boolean expression is true. You do not know beforehand how many times it will spin. While the boolean expression is true the loop spins. Once the boolean expression changes from true to false the loop upon finishing the body stops. The While Loop To understand the while loop first we need to look at an analogy. Imagine that you enter a large office room where you must get all this work done. You need to get into the room and clean each desk in the room. You are a very methodical worker so you only clean one desk at a time. This means that you wipe off the desk sweep under it and empty the waste barrel for each desk rather than empty all the barrels at once or sweep under all the desks first. Another stipulation about how you work is that you can only work in the room if the light is on. It s on an automatic timer. You go to the door and check to see if the light is on. If it is you enter the room and start to work. You will work in the room as long as the light is on. At some point you expect the lights to go off since they are on an automatic timer that someone else set. When the lights go off you 122 Chapter 7 Loops or How to Spin Effectively finish the work at the desk you are at and then leave the room. In a sense you work -while the lights are on. You do each task as outlined in the following description. while lights are on check the lights here Enter body of loop to do your work.

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.