[Solved] Dots in printf in C++


If you are puzzled about the dots here is what they are:

  • %.1lf is the format specification for precision. This is requesting one digit after the decimal point in the printf output.
  • The 1. and 2. in (a*1.+b)/2. mean that those literals are double (as opposed to 1 that would be int and 1.f that would be float). Whoever wrote that snippet was probably trying to avoid truncation in computing that average (given a and b are int).

solved Dots in printf in C++