What is wrong with this code? my book says it's ok, but not my compiler.:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x = 0.0;
double n = 1;
cout << "Number to round: ";
cin >> x;
cout << "Decimal places: ";
cin >> n;
x = x * pow(10, n);
x = x + 0.5;
x = floor(x);
x = x / pow(10, n);
cout << x << endl;
return 0;
}
The 'n's in 'pow' don't read but numbers do.
