In: Computer Science
Write a program that asks the user for a Fahrenheit temperature and calls a function name Celsius that returns the temperature in Celsius of the Fahrenheit temperature sent to it. Your function will look similar to this: double celsius(double f)
{
double c;
:
:
return c;
}
Note: If you like my efforts then do upvote this answer. I am investing a lot of effort in solving the questions.
Below is the C implementation
-------------------------------------------------------------------
#include <stdio.h>
double celsius(double fahrenheit){
// Fahrenheit to celsius conversion
double a = (fahrenheit - 32)*5/9;
return a;
}
void main()
{
double fahrenheit;
printf("\nEnter temperature in Fahrenheit:");
scanf("%lf",&fahrenheit);
double new = celsius(fahrenheit);
// Print the result
printf("\nCelsius = %lf",new);
}
----------------------------------------------------------------------
Code Snapshot with output: