Execution

Computer Program

A computer program is a set of instructions that tells a computer what to do. The computer follows those instructions one by one, in order, from top to bottom.

instruction 1  →  run
instruction 2  →  run
instruction 3  →  run
   result

Programs are lists of instructions#

Every program — no matter how complex — is just a sequence of individual steps. The computer doesn’t read ahead, make assumptions, or skip around. It runs instruction 1, then instruction 2, then instruction 3, and so on until it reaches the end.

Running a Program

Running a program means telling the computer to execute the instructions in your code, one by one, from start to finish.

What Happens When You Run a Program#

When you run a program, the computer reads your source code and starts executing it from the beginning. Each instruction is carried out in order. If the program asks for input, execution pauses until the user responds. If the program produces output, it appears immediately. When the last instruction is done, the program exits.