O'Reilly logo

Sams Teach Yourself C++ in One Hour a Day, Seventh Edition by Siddhartha Rao

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required