Sample chapter: Using decision statements

After completing this chapter from Microsoft Visual C# Step by Step, 8th Edition, you will be able to:

        • Declare Boolean variables.
        • Use Boolean operators to create expressions whose outcome is either true or false.
        • Write if statements to make decisions based on the result of a Boolean expression.
        • Write switch statements to make more complex decisions.

Chapter 3, “Writing methods and applying scope,” shows how to group related statements into methods. It also demonstrates how to use parameters to pass information to a method and how to use return statements to pass information out of a method. Dividing a program into a set of discrete methods, each designed to perform a specific task or calculation, is a necessary design strategy. Many programs need to solve large and complex problems. Breaking up a program into methods helps you to understand these problems and focus on how to solve them, one piece at a time.

The methods in Chapter 3 are very straightforward, with each statement executing sequentially after the previous statement completes. However, to solve many real-world problems, you also need to be able to write code that selectively performs different actions and that takes different paths
through a method depending on the circumstances. In this chapter, you’ll learn how to accomplish this task.

Read the complete chapter here.

Comments (0)

Skip to main content