Basically if I write 15.20 I want 15.20 to return and if I write without any extra zeros or any rounding so that the 0 is still printed out. I tried using setprecision, but it just adds a bunch of zeros.
my code:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double flyttal;
cout << "Skriv in ett flyttal: ";
cin >> flyttal;
cout << "Du skrev in flyttalet: " << fixed << setprecision(2) << flyttal << endl;
return 0;
}
Now thats fine for the float value 15.20 but if I want to write 1.315456 I will only get 1.32. I want to be able to get the same amount of decimals as I put in.