Intro., Input & Output (I/O), if, while, do-while, for

As an introduction to programming in C++, let's use an example program to convert between Fahrenheit and Celsius temperatures. These examples assume you already have some knowledge of a programming language involving variables and assignment, decision and looping statements, and input/output (I/O).

  1. Minimal essentials, Output, semi-colon, comments (/* */), newline
  2. Variables, I/O, expressions, comments (//), arithmetic, precedence
  3. if statement, assignment (=), indentation, blocks {}, exit(-1), sanity checks (assert, system)
  4. while loop, display format size (e.g. %4d, do loop
  5. for loop
  6. break, switch, and continue statements

See the handout for some of the above examples.

Note that in the examples above you can move the bar between the two windows to make one of them (top or bottom) larger.