- Statements are executed one after the other in the order in which they're written -- this is called sequential execution
- Various C++ statements enable you to specify that the next statement to execute is not necessarily the next one in sequence. This is called transfer of control.
- All program can be written in terms of only sequence, selection and iteration
- The sequence structure is built into C++. Unless otherwise directed, the computer executes C++ statements one after the other in the order in which they're written.
- A UML activity diagram models the workflow of a a software system. Such workflows may include a portion of an algorithm
- Activity diagrams are composed of symbols, such as action-state symbols, diamonds and small circles. These are connected by transition arrows, which represent the flow of the activity -- that is, the order in which the actions should occur
- Like pseudocode, activity diagrams help you develop and represent algorithms
- An action state contains an action expression that specifies a particular action to perform
- Transition arrows in the activity diagram represent transitions specifying the order in which the actions represented by the action states occur.
- A solid circle at the top of the activity diagram represents the initial state-- the beginning of the workflow before the program performs the modeled actions
- A solid circle surrounded by a hollow circle at the bottom of the diagram represents the final state -- the end of the workflow after the program performs its actions
- UML notes (like comments in C++) are explanatory remarks that describe the purpose of symbols in the diagram. A dotted line connects each note with the element it describes.
- The "if" single-selection statement performs (selects) an action if a condition is true, or skips it, if the condition is false
- The "if . . . else" double-selection statement performs an action if a condition is true and performs a different action if the condition is false.
- The switch multiple-selection statement performs one of many different actions depending on the value of an expression.
- C++ provides for iteration statements called repetition statements or looping statements that enable programs to perform statements repeatedly as long as loop-continuation condition remains true
- The iteration statements are "while," "do. . .while," "for," and range-based "for statements.
- The "while" and "for" statements perform the action in their bodies zero or more times if the loop-continuation is initially false, the action will not execute
- The "do...while" statement performs its body actions one or more times
- Each of the words "if," "else," "switch," "while," "do," and "for," is a C++ keyword. Keywords cannot be used as identifiers such as variable name and must be spelled with only lower case letters
- Every program is formed by combining as many control statements as is appropriate for the algorithm the program implements
- Single-entry/single-exit control statements make it easy to build programs by connecting the exit point of one to the entry entry point of the next. This is control-statement stacking
- In control-statement nesting, one control statement appears inside another