need help with decimal places

I need to average 5 test scores (0, 92.8, 100, 100, 100) and i have to get an average of 78.6 but i keep getting 78.56. I also need the average of 100, 100, 100, 100, and 105 and my output has to be 101.0 instead i just get 101.


Last edited on
You may want to have a look here: http://www.cplusplus.com/reference/cmath/round/

Kind regards, Nico
It sounds like your real question is this:

How can I output a value to one decimal place?


#include <iomanip> at the top, change line 41 to: cout << "Average: " << fixed << setprecision(1) << average << endl;



I've seen
std::fixed << std::showpoint << std::setprecision(1)
also. Not sure if std::showpoint is needed.
Last edited on
Topic archived. No new replies allowed.