Write C a program that uses a function to convert a temperature from Fahrenheit scale to Celsius scale.

C Programming Language / Function in C Language

1090

Program:

#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;
} 

Output:

 Temperature in Fahrenheit scale: -40
-40.000000 Fahrenheit equals -40.000000 Celsius

 

Explanation:

None

This Particular section is dedicated to Programs only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.