If you are puzzled about the dots here is what they are:
%.1lfis the format specification for precision. This is requesting one digit after the decimal point in theprintfoutput.- The
1.and2.in(a*1.+b)/2.mean that those literals aredouble(as opposed to1that would beintand1.fthat would befloat). Whoever wrote that snippet was probably trying to avoid truncation in computing that average (givenaandbareint).
solved Dots in printf in C++