Course Web Pages

Related Links

Free eBooks


Flow control

The videos below demonstrate the use of flow control in a C++ program with examples from  Dawson's Beginning C++ book. 

if statements

if-else statements

switch statements

while

do while

Boolean (logical) operators

Random Numbers

Game Loop, Flow Diagram

Guess My Number

Naming Conventions

Different organizations have their own conventions for variable names. See, for example, the Variable Names entry in Google's Style Guide for C++. The important thing is to use meaningful names, be consistent, and pay attention to conventions used by the wider programming community.

Exercise

From Beginning C++ Through Game Programming:

Write a new version of the Guess My Number program in which the player and the computer switch roles. That is, the player picks a number and the computer must guess what it is.