Lesson 6. Controlling Program Flow

Most applications need to perform differently under different situations or with user inputs. To enable your application to react differently, you need to be able to program conditional statements that execute different code segments in different situations.

In this lesson, you find out

• How to make your program behave differently on certain conditions

• How to execute a section of code repeatedly in a loop

• How to better control the flow of execution in a loop

Conditional Execution Using if ... else

Programs you have seen and composed this far have a serial order of execution—from top down. Every line was executed and no line was ever ignored. But, serial execution of all lines of code in a top-down fashion ...

Get Sams Teach Yourself C++ in One Hour a Day, Seventh Edition 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.