how to FIELDS OF WIDTH and format decimal place

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

int main()
{
float f,c;





cout<< "Fahrenheit\tCentigrade" <<endl;

for(f=-50; f<=300; f=f+10){
c=(f-32)*5/9;


cout <<f<< "\t \t"<<c <<endl;







//OUTPUT BOTH f and c in FIELDS OF WIDTH 5
//AND FORMAT f WITH NO DECIMAL PLACE
//AND c WITH ONE DECIMAL PLACE


cout<< setprecision(1)<<fixed<<setw(5)<<f<<"\t \t"<<endl;
cout<<setprecision(1)<<fixed<<setw(5)<<c<<endl;




}


return 0;

}

Last edited on
Topic archived. No new replies allowed.