I am still quite new in the C++ business.
I want to output a float number with only one decimal number.
At first I thought it would work with Modulo (%), but I quickly discarded this. Then I wanted to solve it calculated, but I couldn't solve this.
There is also a clue. I can only use <iostream>
and <fstream>
.
But now I came across the function setprecision().
My output code is.
cout<<fixed<<setprecision(2)<<variable<<endl;
However, it outputs e.g. 2.99. I need 2.9 though.
cout<<fixed<<setprecision(1)<<variable<<endl;
Outputs 3.0, though.
Please help me, I will be infinitely grateful. :)