APPLYING CONDITIONAL LOGIC


Conditional logic is easy to use and understand. We employ it in our daily lives to make basic decisions. For example, when shopping, we might decide to buy an item or not based on its sale price. Likewise, based on what time we awake in the morning, we might decide to rise or sleep a little longer. There is really no difference between this type of logic and the conditional logic that you'll learn to apply in your Visual C++ applications.

Underlying any conditional logic test is an evaluation that resolves to either true or false. Based on the results of this test, different actions might be taken. To help facilitate the development of conditional logic, Visual C++ gives you two different statements, each of which is suited to different situations. These statements are as follows:

  • if. This statement provides the ability to test a condition and, based on the result, execute one or more program statements.

  • switch. This statement allows you to perform several tests against a single value and to execute one or more statements if the value matches another value.




Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner 2006
Microsoft Visual C++ 2005 Express Edition Programming for the Absolute Beginner 2006
ISBN: 735615381
EAN: N/A
Year: 2005
Pages: 131

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