How to not display decimal points

While trying to make a basic code to convert and display temperature, I need the program to show no decimal places so I use cout.precision(0) when I do that it gives me scientific notation
Example
2e-02 when I simply want it to drop the .22 of 22.22

You could just cast it to an int.
 
cout << "Temp:" << static_cast<int>(temprature);
Cast to int will truncate, if the value was 18.89, it would be better to round it up.

Try cout << fixed; or cout.setf(ios::fixed);, this affects the way the precision is interpreted.
It is for a school assignment. So I have to use certain basic codes. Else that would work!
You could use cmath and the ceiling/floor functions.
@chevril
What do fixed and cout.setf(ios::fixed) do ?

edit: nvm looked it up.
Last edited on
Thanks guys that works!!
Topic archived. No new replies allowed.