+ 2
So I take it that formatting the output of a number to look like it is only 2 decimals is NOT what you want.
In that case, the best way to do it comes from the <math.h> library.
Pretend the number you wish to round is 3.45678. We know it rounds to 3.46. C has a method in <math.h> that rounds to the nearest integer. So if we convert 3.45678 to 345.678 by multiplying by 100, then it will round to 346.000. Then all that is left for us to do is divide 346.000 by 100 and it returns the value to 3.46. After that just assign it to the variable you want to use in the next operations and you will have the rounded off number.



