jeudi 29 août 2019

fixed and setprecision in c++

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
    float c = 5.0;
    float far = (9/5)*c + 32;
    cout << fixed << "Temperature in Fahrenheit is "<< setprecision(2) << 
    far;
    return 0;
} 

I expected the output to be 41.00, but the actual output is 37.00.

Aucun commentaire:

Enregistrer un commentaire