Program Flow
Programs are recipes that have particular start spots and special rules on how the computer follows them. In general, a program will start at some "main" routine and continue "downward," one line at a time, until the end of the function is reached. Any time another function is encountered, all lines of code inside that function will be completed before continuing in the current function. Any time an "if" statement is reached, a decision will be made on whether to execute one set of statements or another. Any time a loop is reached, a set of statements may be repeated zero or more times.
Program Flow
Programs are executed in a well-defined manner. In the absence of specific "Control Structures," code always "flows":
From Top to Bottom (from left to right)
In a single line of code
In any particular line of code, the following order of operations happens:
parenthetical statements are computed first (those inside of parentheses); everything to the right of an assignment statement
finally, the assignment itself (if there is one)
Road Signs for Code (Control Statements)
Often there are "road signs" that affect which is the next piece of code to be executed. The common "road signs" are: