Chapter 3Decisions and Loops

  • How to compare data values
  • How to alter the sequence of program execution based on the result
  • How to apply logical operators and expressions
  • How to deal with multiple choice situations
  • How to write and use loops in your programs

You can find the wrox.com code downloads for this chapter on the Download Code tab at www.wrox.com/go/beginningvisualc. The code is in the Chapter 3 download and individually named according to the names throughout the chapter.

COMPARING VALUES

Unless you want to make decisions on a whim, you need a mechanism for comparing things. This involves some new operators called relational operators. Because all information in your computer is ultimately represented by numerical values (in the last chapter you saw how character information is represented by numeric codes), comparing numerical values is the essence of all decision making. You have six operators for comparing two values:

< less than <= less than or equal to
> greater than >= greater than or equal to
== equal to != not equal to

Each operator compares the values of two operands and returns one ...

Get Ivor Horton's Beginning Visual C++ 2013 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.