Codeville Your program is like a network of roads

Programs need to do different things under different circumstances. In the game, the code displays "You win!" if the user guesses the number correctly, and "You lose!" if not. This means that all programs, even really simple programs, typically have multiple paths through them.

The dompu-teir ru»s {he

H take though the code-

There ave ma*y v-oads (or paths) through the ¿ode.

The dompu-teir ru»s {he

H take though the code-

There ave ma*y v-oads (or paths) through the ¿ode.

A path refers to the set of instructions that the computer will actually follow (or execute). Your code is like a street network, with lots of sections of code connected together just like the streets in a city. When you drive through a city, you make decisions as to which streets you drive down by turning left or right at different intersections. It's the same for a program. It also needs to make decisions from time to time as to which path to take, but for your code, it is not like driving along a road, it's executing a particular path.

Let's look in more detail at how a program decides which path to take.

fork in the road

Was this article helpful?

0 0

Post a comment