### rounding

this program is supposed to output rounded numbers for a whole number,
and decimal places for tenth, hundredth, and thousandth, but my output
only outputs whole numbers.

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849`` `````` #include #include #include #include using namespace std; int whole(double); int tenth(double); int hund(double); int thous(double); int main() { int a, b, c, d; double num; cout << "Input a number to be rounded to the nearest whole number, tenth, hundredth, and thousandth place." << endl; cin >> num; a = whole(num); cout << a << endl; b = tenth(num); cout << setprecision(1) << fixed << b << endl; c = hund(num); cout << setprecision(2) << fixed << c << endl; d = thous(num); cout << setprecision(3) << fixed << d << endl; return 0; } int whole(double x) { double y = floor (x + .5); return y; } int tenth(double x) { double y = floor (x * 10 + .5) / 10; return y; } int hund(double x) { double y = floor (x * 100 + .5); y = y / 100; return y; } int thous(double x) { double y = floor (x * 1000 + .5) / 1000; return y; }``````
Take a look at your return types.
oh wow, thank you.
Topic archived. No new replies allowed.