Sunday, March 29, 2009

Calculate temperature in Celcius from Fahrenheit

/*Calculate temperature in Celsius with input of temp in fahrenheit ,while call function to calculate temp in Cel from fahr' and return value to calling function and display value returned by your functions*/

#include
float temp(float fah); //function temp calculates input fahrenheit to Celsius fah is formal parameter
int main(void)
{
float far; // here far is actual parameter whose value is stored in fah formal parameter ,so far => fah
printf("Enter temperature in Fahrenheit : ");
scanf("%f",&far);
printf("\nTemperature in Celcius is %f",temp(far));
return 0;
}

float temp(float fah)
{
return ( 5 * ( fah - 32))/9;
}

No comments: