Completion requirements
Read this chapter, which reviews how computers make decisions using if statements. As you read this tutorial, you will understand that sometimes it is important to evaluate the value of an expression and perform a task if the value comes out to be true and another task if it is false. In particular, try the simulated program under the heading "Simulated Program" to see how a different response is presented to the user based on if a number is positive or negative.
Pay special attention to the "More Than One Statement per Branch" header to learn how the 'else' statement is used when there is more than one choice.
19. Last Page
Answer:
Yes. And you can have two nested if
statements, one per branch.
Last Page
This is the end of the chapter. If you want, review the following topics; else, go on to the next chapter.
- two-way decision Two-way decisions.
- two-way decision, details Outline of a Two-way decision.
- block statement Statement blocks.
- boolean expression Boolean Expressions.
- relational operators, table Table of Relational Operators.