code in C At the computer write a program to create a table of temperature conve
ID: 3705634 • Letter: C
Question
code in C
At the computer write a program to create a table of temperature conversions from Celsius to Fahrenheit and to Kelvin.. In function main prompt the user to enter the starting value in degrees Celsius, the increment between Celsius values and the final value in Celsius for the table. Print the table of Celsius, Fahrenheit, and Kelvin temperatures. Include column headings. Use integer values for degrees Celsius and floating point values for Fahrenheit and kelvin. Place degrees Celsius in the column on the left, Fahrenheit in the second column and then Kelvin in the third column. Print Fahrenheit and Kelvin temperatures with two decimal digits. The formulas for the conversion are: F (9/5)C + 32 K C 273.15Explanation / Answer
Steps:
Code is to converting celsius to fahrenheit & Kelvin...............first taking the total no.of celsius readings as a input and converting them into Fahrenheit & Kelvin.Printing them in the tabular format.
//////////////////////////////////////////////////////////////////////code///////////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
int main()
{
int input,i;
float celsius[1000], fahrenheit,kelvin;
printf("Enter the no.of celsius readings that you to convert: ");
scanf("%d",&input);
printf("Please Enter the Celsius Readings one after another : ");
for(i=0;i<input;i++){
scanf("%f", &celsius[i]);
}
printf("Here are the Converted Reading....... ");
printf("celsius--------------fahrenheit-----------kelvin ");
for(i=0;i<input;i++){
fahrenheit = ((9/5) * celsius[i]) + 32;
kelvin = 273.15 + celsius[i];
printf("%.2f----------------%.2f----------------%.2f ",celsius[i],fahrenheit,kelvin);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.