#include <stdio.h>
float FtoC(float);
int main(void)
{
float tempInF;
float tempInC;
printf("\n Temperature in Fahrenheit scale: ");
scanf("%f", &tempInF);
tempInC = FtoC(tempInF);
printf("%f Fahrenheit equals %f Celsius \n", tempInF,tempInC);
return 0;
}
/* FUNCTION DEFINITION */
float FtoC(float faren)
{
float factor = 5.0/9.0;
float freezing = 32.0;
float celsius;
celsius = factor*(faren - freezing);
return celsius;
}
Temperature in Fahrenheit scale: -40
-40.000000 Fahrenheit equals -40.000000 Celsius
First understand the algorithm carefully. Then study the program line-by-line and compare it with the output. Finally, review the explanation section to strengthen your logic and programming understanding.
Rewrite the program without looking at the code. Modify values, conditions or logic and run it again. This helps improve confidence and strengthens coding skills much faster.