How do computers make decisions? Here are a few examples:
Each of these programs is a set of instructions, executed in a certain order. This order, called control flow, is just as important as the instructions themselves.
Programmers use control structures to alter control flow. Control structures include conditionals — “do these instructions if Z is true”, loops — “do these instructions X many times”, and exceptions — “do instruction set A, but if an error occurs switch to instruction set B”. Programmers use these structures in their code to tell a computer which instructions (or in which order) to execute.
In this lesson you will learn the fundamental concepts of control flow and three essential control structures. By the end of the lesson you should be able to:
There are five steps in this program, which loads a basic website. Execute the steps in the correct order by clicking each one.
In what order are the instructions executed?