Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I would like you to write a C Program to convert user input of the temperature i

ID: 3649428 • Letter: I

Question

I would like you to write a C Program to convert user input of the temperature in Fahrenheit to Celcius, Rankin(e), and Kelvin

include <stdio.h> //for printf and scanf

int main()
{
// Declare variables
double celsius, fahrenheit;

// Input
printf("Please enter a temperature in Fahrenheit: ");
scanf("%lf", &fahrenheit); // Read input from user, store in
// fahrenheit
fflush(stdin); // Flush input buffer

// Calculation
celsius = (5.0/9.0) * (fahrenheit - 32); // We must use 5.0
// because we are playing with floating point
// numbers and don't want to do integer division.

// Output
printf("%4.1f degrees fahrenheit = %4.1f degrees celsius ", fahrenheit, celsius); // Variables are given from left to right

getchar(); // For those icky windows compilers
return 0;
}

Explanation / Answer

#include main () { float temp_c, temp_f, temp_r, temp_k; printf ("Enter the value of Temperature in Fahrenheit: "); scanf ("%f", &temp_f); temp_c = ( temp_f - 32)/1.8; temp_r = (temp_f - 459.67); temp_k = (temp_f + 459.67)*5/9; printf ("The value of Temperature in Celsius is: %f", temp_c); printf ("The value of Temperature in Rankine is: %f", temp_r); printf ("The value of Temperature in Kelvin is: %f", temp_k); }