C++ Write a program that converts Fahrenheit temperatures to Celsius. Display co
ID: 3760515 • Letter: C
Question
C++
Write a program that converts Fahrenheit temperatures to Celsius. Display conversions from 0-212 with
3 digits of precision. Use: Celsius = 5.0 / 9.0 * (Fahrenheit – 32); Example Program Session:
FC
0 -17.778
1 -17.222
2 -16.667
3 -16.111
... repeats
203 +95.000
204 +95.556
205 +96.111
206 +96.667
207 +97.222
208 +97.778
209 +98.333
210 +98.889
211 +99.444
212 +100.000
My Code:
#include <iostream>
#include<math.h>
using namespace std;
int main() {
printf("F C ");
for (int i=0; i<=212; i++) {
float c = (5.0/9.0)*(i-32.0);
printf("%d %3.3f ", i, c);
}
cout<<" ";
return 0;
}
"You did not put in the required system pause so your output flashed on my screen and disappeared." ???
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
setprecision(3);
cout << "F -> C" << endl;
for(int i=0;i<=212;i++)
{
cout << i << " -> " << (5.0/9.0)*(i-32) << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.