Review of What We have Learned
  1. C++ is a programming language that is: compiled, high-level and object-oriented.
  2. C++ can be used in a variety of programming tasks.
We have seen 4 ways to organize our code:
  1. Sequence
  2. Selection
  3. Iteration
  4. Functions

-When we use sequence, what we put first happens first.

-All variables and function names must be declared before their first use. We use header files to declare our functions so we can use them in other files.

-Selection allows to make a choice.

-Our most basic selection statement is the if statement.

-If statements use boolean expressions to determine truth.

-A boolean statement is one that evaluates to true or false.

Iteration allows us to repeat code until a condition becomes false.

Our most basic loop is the while loop.

We need to use a boolean expression again on our loops. The big difference is that in a loop the loop statements are repeated until the condition is false.

In a selection statement the lines of code are only run once...unless the selection is in a loop.

One of the most important loops is the input control loop.

In this loop we have 4 steps

  1. Prime - try to read at least 1 piece of data.
  2. Test - this is the ending condition while ( !in.fail() )

  1. Process - this is the loop body, what the loop is doing.
  2. Re-prime - try to read the next piece of data. It should be the same as the prime.