Could you write a code for this in C language? Please explain youre code in comments so its easy to understand. Please also attach a picture of your code. Thanks
. Write a program to convert a temperature in degrees Fahrenheit to degrees Celsius. DATA REQUIREMENTS
Problem Input
int fahrenheit /* temperature in degrees Fahrenheit */
Problem Output
double celsius /* temperature in degrees Celsius */
Relevant Formula
celsius = 5/9 ( fahrenheit − 32) A sample of program output is displayed below
____End of Assignment __________________________________________________________
Expert Answer
#include <stdio.h>
int main()
{
/* Declare the necessary variables */
int fahrenheit; /* input variable to store temperature in degrees Fahrenheit */
double celsius; /* output variable where resultant temperature will be stored in degrees Celsius */
/* input is taken from user*/
/*as specified in question input should be Integer type of data*/
printf(“nEnter temperature in Fahrenheit(Integer Number): “);
scanf(“%d”, &fahrenheit);
/* Fahrenheit to celsius conversion formula is used : celsius = 5/9 ( fahrenheit – 32) */
celsius =(double)5/9*(fahrenheit – 32) ; /* as the output variable is double,so we have to use explicit casting for integer division 5/9 */
/* Print the output result*/
printf(“n%d Fahrenheit(in degree) = %f Celsius(in degree)”, fahrenheit, celsius);/* output will print fractional values up to six decimal places*/
return 0;
}
/* picture of code*/
/* pictures of outputs:*/