Logic and choice

In this chapter we will learn more about how computers use logic and can choose between different options. In this way, our programs become smarter!

Your alarm clock (or the alarm on your phone) has a simple if statement: Is the current time equal to the time saved? If so, the alarm should ring, and otherwise nothing happens.

Alarm systems for houses or office buildings use various sensors that tell if a door has been opened or if they have seen any movement. The information comes to the computer as with the if-statement "has any sensor sent a signal?" starts calling the emergency center.