Here's an outline of the fourth week
- Miscellaneous
- More practice with mixed expressions - implicit and explicit type
conversion
- Trick for how to round floats to integers (instead of truncating)
- Trick for swapping the values of two variables
- Precedence of operators (listed in tables), know when and why to look at
the precedence chart
- More on boolean expressions: ! and !=
- Walking (stepping) through a program
- Another multi-way selection structure: switch (form, flowchart, example)
- Loops (repetition structures)
- while (flowchart, form, examples)
- do/while (flowchart, form, examples)
- when to use while vs. do/while (do/while always executes statement
at least once, and checks expression after executing statement)
- for (flowchart, form, examples)
- controlling loops: counters, sentinels, flags
- Controlling loops with while: don't forget to initialize variables
before loop and to update them after the loop
- Controlling counter-controlled loops with for: worry about what
value to start counter,
worry about if loop condition should be < or <=, worry about
how to increment/decrement/update the counter
- Using pre-defined functions
- Pass values to the function by enclosing them in parentheses
- Functions can return values - you can output them or store them
with assignment statements
- To use predefined math functions (such as sqrt), don't forget to
#include <cmath>