Chapter 4: Using Decision Statements


Chapter 4

Using Decision Statements

After completing this chapter, you will be able to:

  • Declare bool 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.

In Chapter 3, “Writing Methods and Applying Scope,” you learned how to group related statements into methods. You also learned how to use arguments and parameters to pass information to a method and how to use return statements to pass information out of a method. Dividing a program up into a set of discrete methods, each designed to perform a specific task or calculation, is a recommended design strategy. Many programs need to solve large and complex problems. Breaking up a program into methods helps you understand these problems and focus on how to solve them one piece at a time. You also need to be able to write methods that selectively perform different actions depending on the circumstances. In this chapter, you'll see how to accomplish these tasks.




Microsoft Visual C# 2005 Step by Step
Microsoft® Visual C#® 2005 Step by Step (Step By Step (Microsoft))
ISBN: B002CKYPPM
EAN: N/A
Year: 2005
Pages: 183
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net