P5.2 Celsius Temperature Table. The formula for converting a temperature from Fa
ID: 3767267 • Letter: P
Question
P5.2 Celsius Temperature Table. The formula for converting a temperature from Fahrenheit to Celsius is
C = (F – 32),
where F is the Fahrenheit temperature and C is the Celsius temperature. Write a function named celsius that accepts a Fahrenheit temperature as an argument. The function should return the temperature, converted to Celsius. Demonstrate the function by calling it in a loop that displays a table of the Fahrenheit temperatures 0 through 20 and their Celsius equivalents
C++
ahrenheit Celsius 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 12.0 13.0 14.0 15.0 16.0 17.0 18.0 19.0 20.0 -16.7 -16.1 -15.6 -15.0 -14.4 -13.9 -13.3 -12.8 -12.2 -10.6 -10.0 -9.4 -8.9 -8.3 ress any key to continue -. .Explanation / Answer
c++ code :
#include <bits/stdc++.h>
using namespace std;
double ftoc(double f){
return (f-32.0)/1.8;
}
int main(){
cout << fixed << setprecision(1) ;
double f=0.0;
cout<<"Fahrenheit Celsius"<<endl;
cout<<"------------------------"<<endl;
while(f<=20.0){
cout<<" "<<left<<f<<" "<<left<<ftoc(f)<<endl;
f=f+1.0;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.