Decisions and Loops
Ivor Horton · 2010
This chapter looks at how to add decision - making capabilities to C++ Programs and how to make programs repeat a set of actions until a specific condition is met. This will enable to handle variable amounts of input, as well as make validity checks on the data that you read in. This chapter starts with one of the most powerful and fundamental tools in programming: the ability to compare variables and expressions with other variables and expressions and, based on the outcome, execute one set of statements or another. All the loop statements that have been discussed apply equally well to C++/CLI programs, and the C++/CLI language provides the luxury of an additional kind of loop called the for each loop. This loop also works with native C++ code in Visual C++ 2010, although formally the for each loop is not part of the ISO/IEC standard C++ language.