CH05 - An Introduction to Programming with C+, Fifth...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
An Introduction to Programming with C++, Fifth Edition 5 - 1 Chapter 5 The Selection Structure At a Glance Instructor’s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Topics Classroom Activities/Additional Projects Key Terms
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
An Introduction to Programming with C++, Fifth Edition 5 - 2 Lecture Notes Chapter Overview This chapter covers one of the basic control structures used in programming, which is the selection structure. Proper design of the selection structure is covered using both pseudocode and flowcharts. The syntax of both if and if/else is covered, which is the programming code that implements the selection structure in C++. Comparison and logical operators are introduced in order to represent conditions; while comparison of numeric, as well as character and string data, is covered. Chapter Objectives After completing the chapter, the student will be able to: Write pseudocode for the selection structure Create a flowchart for the selection structure Code the if and if/else forms of the selection structure Write code that uses comparison operators and logical operators Convert the contents of a char variable to uppercase or lowercase Convert the contents of a string variable to uppercase or lowercase Use the .NET ToUpper(), ToLower(), and CompareTo() methods Instructor Notes Using the Selection Structure The selection structure, also called the decision structure, is one of the three basic control structures used in programming. The other two are sequence, which has been covered previously, and the repetition structure, which will be covered in a later chapter. The selection structure is used when you would like the program to make a decision, or comparison. Dependent upon the outcome of the decision, one of two paths will be chosen (the true path or the false path). Note that the decision within the selection structure will also result in either true or false, which is called a boolean result. Writing Pseudocode for the If and If/Else Selection Structures Even though flowcharts are commonly used in representing selection structures, many programmers still wish to use pseudocode. You should always use whichever design method is
Background image of page 2
An Introduction to Programming with C++, Fifth Edition 5 - 3 most effective for you. Many programmers will use a combination of flowcharts and pseudocode.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
An Introduction to Programming with C++, Fifth Edition 5 - 4 Different programming structures may lend themselves to being designed in either a flowchart or pseudocode. See Figure 5-2 on page 232 for an example of a selection structure in pseudocode. Flowcharting the If and If/Else Selection Structures While the concept of a selection structure is quite simple, it is important to properly design the selection structure. Both flowcharts and pseudocode have been covered previously (review if necessary). However, new flowchart symbols will now be introduced. The diamond symbol
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 9

CH05 - An Introduction to Programming with C+, Fifth...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online