The following problems generate temperature-conversion tables, write the code fo
ID: 3779238 • Letter: T
Question
The following problems generate temperature-conversion tables, write the code for each part using the following equations that give relationships between temperatures in degrees Fahrenheit degrees Celsius degrees Kelvin and degrees Rankin: T_F = T_R - 459.67 degree R T_F = (9/5)T_C _ 32 degree F T_R = (9/5)T_K Write a program to generate a table of conversions from Fahrenheit to Celsius for values from 0 degree F to 100 degree F. Print a line in the table for each 5 degree change. Use a while loop in your solution. Write a program to generate a table of conversions from Fahrenheit to Kelvin for values from 0 degree F to 200 degree F. Allow the user to enter the increment in degrees Fahrenheit between lines. Use a do while loop in your solution. Write a program to generate a table of conversions from Celsius to Rankin. Allow the user to enter the starting temperature and increment between lines. Print 25 lines in the table. Use a for loop in your solution.Explanation / Answer
#include <stdio.h>
int main(){
//Tc = 5/9*(Tf - 32) eq 2
printf("Tf Tc ");
double tf = 0.0;
while(tf <= 100.0){
double tc = (tf - 32)*5/9;
printf("%lf %lf ",tf, tc);
tf+=5;
}
//Tk = 5/9 * (Tf + 459.67) from eq 1 and 3
double increment = 5;
tf = 0.0;
printf("Enter the increment level for foreinheit to Kelvin conversion: eg 5 or 10 : ");
scanf("%lf", &increment);
printf("Tf Tk ");
do{
double tk = (tf + 459.67)*5/9;
printf("%lf %lf ",tf, tk);
tf+=increment;
}while(tf <= 200.0);
//Tr = Tf+459.67 = (9/5Tc + 32) + 459.67 = 9/5 * Tc + 491.67
double tc = 0;
printf("Enter the starting temperature for Celcius to Rankin conversion : ");
scanf("%lf", &tc);
printf("Enter the increment level : eg 5 or 10 : ");
scanf("%lf", &increment);
int index= 0;
for(index = 0; index < 25; index++){
double tr = 491.67 + (tc*9/5);
printf("%lf %lf ",tc, tr);
tc+=increment; //Incrementing the tc
}
return 0;
}
Output :
Tf Tc
0.000000 -17.777778
5.000000 -15.000000
10.000000 -12.222222
15.000000 -9.444444
20.000000 -6.666667
25.000000 -3.888889
30.000000 -1.111111
35.000000 1.666667
40.000000 4.444444
45.000000 7.222222
50.000000 10.000000
55.000000 12.777778
60.000000 15.555556
65.000000 18.333333
70.000000 21.111111
75.000000 23.888889
80.000000 26.666667
85.000000 29.444444
90.000000 32.222222
95.000000 35.000000
100.000000 37.777778
Enter the increment level for foreinheit to Kelvin conversion: eg 5 or 10 : 10
Tf Tk
0.000000 255.372222
10.000000 260.927778
20.000000 266.483333
30.000000 272.038889
40.000000 277.594444
50.000000 283.150000
60.000000 288.705556
70.000000 294.261111
80.000000 299.816667
90.000000 305.372222
100.000000 310.927778
110.000000 316.483333
120.000000 322.038889
130.000000 327.594444
140.000000 333.150000
150.000000 338.705556
160.000000 344.261111
170.000000 349.816667
180.000000 355.372222
190.000000 360.927778
200.000000 366.483333
Enter the starting temperature for Celcius to Rankin conversion : 10
Enter the increment level : eg 5 or 10 : 5
10.000000 509.670000
15.000000 518.670000
20.000000 527.670000
25.000000 536.670000
30.000000 545.670000
35.000000 554.670000
40.000000 563.670000
45.000000 572.670000
50.000000 581.670000
55.000000 590.670000
60.000000 599.670000
65.000000 608.670000
70.000000 617.670000
75.000000 626.670000
80.000000 635.670000
85.000000 644.670000
90.000000 653.670000
95.000000 662.670000
100.000000 671.670000
105.000000 680.670000
110.000000 689.670000
115.000000 698.670000
120.000000 707.670000
125.000000 716.670000
130.000000 725.670000
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.