- 4.1 Introduction
- 4.2 Algorithms
- 4.3 Pseudocode
- 4.4 Control Structures
- 4.5 If...Then Selection Statement
- 4.6 If...Then...Else Selection Statement
- 4.7 Nested If...Then...Else Statements
- 4.8 Repetition Statements
- 4.9 Compound Assignment Operators
- 4.10 Formulating Algorithms: Counter-Controlled Repetition
- 4.11 Formulating Algorithms: Nested Control Statements
- 4.12 Using the Debugger: Locating a Logic Error
- 4.13 Wrap-Up
- Summary
- Terminology
- Self-Review Exercises
- Answers to Self-Review Exercises
- Quick Quiz
- Exercises
- Making a Difference Exercises
4.13 Wrap-Up
This chapter presented basic problem-solving techniques that you use to build programs. We demonstrated how to develop an algorithm in pseudocode, evolving it through several refinements until it is ready to be translated to Visual Basic code that can be executed. This process is called top-down, stepwise refinement.
You learned that only three types of control structures—sequence, selection and repetition—are needed to develop an algorithm. We demonstrated the If...Then single-selection statement and the If...Then...Else double-selection statement. The If...Then statement is used to execute an action (or sequence of actions) based on a condition—if the condition is true, the statements execute; if it is false, the statements are skipped. The If...Then...Else double-selection statement is used to execute one set of statements if a condition is true, and another set if the condition is false.
We discussed the Do While...Loop and While...End While repetition statements that execute sets of statements repeatedly as long as a loop-continuation condition remains true. We discussed the Do Until...Loop repetition statement, where a set of statements executes repeatedly as long as a loop-termination condition remains false. You studied the UML activity diagrams that represent each control statement presented in the chapter.
We introduced compound assignment operators, which can be used for abbreviating assignment statements. We used control-statement stacking to compute a class average with counter-controlled repetition then display the results, and we used control-statement nesting to analyze and make decisions based on a set of exam results. You also learned how to use the debugger to view the values of variables during program execution and to step through a program to help locate a logic error. In Chapter 5, Problem Solving and Control Statements: Part 2, we present additional selection and repetition statements.