www.gibmonks.com

Main Page




Previous Page
Next Page

[Page 170 (continued)]

Summary

  • An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which to execute them.

  • Specifying the order in which statements (actions) execute in a program is called program control.

  • Pseudocode helps a programmer think out a program before attempting to write it in a programming language.

  • Activity diagrams are part of the Unified Modeling Language (UML)an industry standard for modeling software systems.

  • An activity diagram models the workflow (also called the activity) of a software system.

  • Activity diagrams are composed of special-purpose symbols, such as action state symbols, diamonds and small circles. These symbols are connected by transition arrows that represent the flow of the activity.

  • Like pseudocode, activity diagrams help programmers develop and represent algorithms.

  • An action state is represented as a rectangle with its left and right sides replaced with arcs curving outward. The action expression appears inside the action state.

  • The arrows in an activity diagram represent transitions, which indicate the order in which the actions represented by action states occur.

  • The solid circle located at the top of an activity diagram represents the initial statethe beginning of the workflow before the program performs the modeled actions.

  • The solid circle surrounded by a hollow circle that appears at the bottom of the activity diagram represents the final statethe end of the workflow after the program performs its actions.

  • Rectangles with the upper-right corners folded over are called notes in the UML. Notes are explanatory remarks that describe the purpose of symbols in the diagram. A dotted line connects each note with the element that the note describes.

  • A diamond or decision symbol in an activity diagram indicates that a decision is to be made. The workflow will continue along a path determined by the symbol's associated guard conditions, which can be true or false. Each transition arrow emerging from a decision symbol has a guard condition (specified in square brackets next to the transition arrow). If a guard condition is true, the workflow enters the action state to which the transition arrow points.


    [Page 171]
  • A diamond in an activity diagram also represents the merge symbol, which joins two flows of activity into one. A merge symbol has two or more transition arrows pointing to the diamond and only one transition arrow pointing from the diamond, to indicate multiple activity flows merging to continue the activity.

  • Top-down, stepwise refinement is a process for refining pseudocode by maintaining a complete representation of the program during each refinement.

  • There are three types of control structuressequence, selection and repetition.

  • The sequence structure is built into C++by default, statements execute in the order they appear.

  • A selection structure chooses among alternative courses of action.

  • The if single-selection statement either performs (selects) an action if a condition is true, or skips the action if the condition is false.

  • The if...else double-selection statement performs (selects) an action if a condition is true and performs a different action if the condition is false.

  • To include several statements in an if's body (or the body of an else for an if...else statement), enclose the statements in braces ({ and }). A set of statements contained within a pair of braces is called a block. A block can be placed anywhere in a program that a single statement can be placed.

  • A null statement, indicating that no action is to be taken, is indicated by a semicolon (;).

  • A repetition statement specifies that an action is to be repeated while some condition remains true.

  • A value that contains a fractional part is referred to as a floating-point number and is represented approximately by data types such as float and double.

  • Counter-controlled repetition is used when the number of repetitions is known before a loop begins executing, i.e., when there is definite repetition.

  • The unary cast operator static_cast can be used to create a temporary floating-point copy of its operand.

  • Unary operators take only one operand; binary operators take two.

  • The parameterized stream manipulator setprecision indicates the number of digits of precision that should be displayed to the right of the decimal point.

  • The stream manipulator fixed indicates that floating-point values should be output in so-called fixed-point format, as opposed to scientific notation.

  • Sentinel-controlled repetition is used when the number of repetitions is not known before a loop begins executing, i.e., when there is indefinite repetition.

  • A nested control statement appears in the body of another control statement.

  • C++ provides the arithmetic assignment operators +=, -=, *=, /= and %= for abbreviating assignment expressions.

  • The increment operator, ++, and the decrement operator, --, increment or decrement a variable by 1, respectively. If the operator is prefixed to the variable, the variable is incremented or decremented by 1 first, and then its new value is used in the expression in which it appears. If the operator is postfixed to the variable, the variable is first used in the expression in which it appears, and then the variable's value is incremented or decremented by 1.


Previous Page
Next Page