Saturday 12 December 2015

C Language Program That Convert Temperature From Fahrenheit To Centigrade

WRITE A PROGRAM THAT CONVERT TEMPERATURE FROM FAHRENHEIT TO CENTIGRADE.


#include<stdio.h>       // Header file  “Standard Input and Output”
#include<conio.h>      //Header file “Console input and output”
void main ()
{
            clrscr();                                                            // Clear the output screen
            float temperature;                                            // Variable declaration
           
printf("Enter the temperature in Fahrenheit = ");
scanf("%f", &temperature);

temperature = 5*(temperature - 32)/9;            // Formula: 5/9*(temperature – 32)
printf("\nThe temperature in centigrade is = %f",temperature);

getch();
}

OUTPUT

Enter the temperature in Fahrenheit = 100
The temperature in centigrade is = 37.78

Enter the temperature in Fahrenheit = 58
The temperature in centigrade is = 14.44

EXPLANATION


Simple conversion formula is used in this program. The exact formula is written in the comments.

No comments:

Post a Comment