The Conditional Operator and the 'switch' Statement

Read this chapter, which discusses the switch and '?' operators to write conditional statements. As you read this tutorial, you will learn that sometimes it is better to use a 'switch' statement when there are multiple choices to choose from. Under such conditions, an if/else structure can become very long, obscure, and difficult to comprehend. Once you have read the tutorial, you will understand the similarity of the logic used for the 'if/else' statement, '?', and 'switch' statements and how they can be used alternately.

8. Flowchart of a break Statement


Answer:

0.3

Flowchart of a break Statement

Here is the example program fragment (again) and a flowchart that shows how it works. The box in the flowchart "evaluate code" means to get the current value of code. In a larger program this would usually be different every time.

Annotation 2020-03-09 210049


Question 8:

(Trick Question:) What would be the discount if code were 'a' ?