- In sentinel-controlled iteration, a special value called a sentinel value; also called a signal value, a dummy value or a flag value) is used to indicate "end of data entry."
- Sentinel-controlled iteration is often called indefinite iteration because the number of iterations is not known before the loop begins executing.
- Top-down, stepwise refinement is essential to the development of well-structured programs.
- Begin with a pseudocode representation of the top -- a single statement that, in effect is a complete representation of a program
- The top rarely conveys sufficient detail from which to write a C++ program. So in the first refinement, we refine the top into a series of smaller tasks and list these in the in which they'll be performed. This refinement uses only tasks in sequence
- In the second refinement, we commit to specific variables and logic
- A number with a decimal point is called a real number or floating-point number
- C++ provides types float and double to store floating-point numbers in memory
- "Double" variables can typically store numbers with larger magnitude and finer detail
- C++ also supports type long double for floating-point values with larger magnitude and more precision than "double"
- The static_cast operator converts a temporary copy of its operand in parentheses to the type in angle brackets (double). Using a cast operator in this manner is called explicit conversion.
- For arithmetic, the compiler knows how to evaluate only expressions in which the operand types are identical. To ensure this, the compiler performs an operation called promotion on selected operands.
- In an expression containing values of data types "int" and "double," C++ promotes "int" operands to "double" values
- "static_cast" is a unary operator -- it only has one operand
- C++ also supports unary versions of the plus (+) and minus (-) operators, so that you can write such expressions as -7 or +5
- "Setprecision" is a parameterized stream manipulator that specifies the number of digits of precision to the right of the decimal point when a floating-point number is output.
- Programs that use parameterized stream manipulators must include the header <iomanip>
- The manipulator "endl" (from the header <iostream>) is a nonparameterized stream manipulator because it does not require an argument
- By default, floating-point values are output with six digits of precision
- The stream manipulator "fixed" indicates that floating-point values should be output in fixed-point format as opposed to scientific notation
- Fixed-point formatting forces the decimal point and trailing zeros to print, even if the value is a whole number amount
- When the stream manipulators "fixed" and "setprecision" are used in a program, the printed value is rounded to the number of decimal positions indicated by "setprecision" 's argument, although the value in memory remains unaltered.
- It's also possible to force a decimal point to appear by using stream manipulator "showpoint". If "showpoint" is specified without "fixed, then trailing zeros will not print.
- Nonparameterized stream manipulators "fixed" and "showpoint" require the header <iostream>