C Programming

Solved Example

Practice Questions

Exercise Question

Convert temperature from Fahrenheit to centigrade

Objective

Input the temperature in Fahrenheit and convert it into centigrade/celsius. The following formula is used for the conversion.

C = (F - 32) * 5 / 9

Here C is temprature in centigrade and F is temprature in fahrenheit.

Program/Solution:

#includestdio.h
int main() {
	float f,c;
	printf("Enter the temprature in fahrenheit: ");
	scanf("%f",&f);
	
	c = (f - 32) * 5 / 9;
	
	printf("Temprature in Centigrade: %.2f",c);
	
	return 0;
}

Sample Output:

Enter the temprature in fahrenheit: 100
Temprature in Centigrade: 37.78