C Program to Find Total of Even Integers

C Program to Convert Temperature From Fahrenheit to Celsius

This C program converts the given temperature in Fahrenheit to Celsius using the following conversion formula and explain with simple steps,

Temperature measurement in today’s industrial environment encompasses a wide variety of needs and applications. To meet this wide array of needs the process controls industry has developed a large number of sensors and devices to handle this demand.

C = -F – 32 /1.8

C Program to Convert Temperature in Fahrenheit to Celsius

#define F_LOW 0 /* --------------------- */
#define F_MAX 250 /* Symbolic Constants */
#define STEP 25 /* --------------------- */
main()
{
    typedef float REAL ; /* Type Definition */
    REAL fahrenheit, celsius ; /* Declaration */
    fahrenheit = F_LOW ; /* Initialization */
    printf("Fahrenheit Celsius\n\n") ;
    while( fahrenheit <= F_MAX )
{
     celsius = ( fahrenheit - 32.0 ) / 1.8 ;
     printf(" %5.1f %7.2f\n", fahrenheit, celsius);
     fahrenheit = fahrenheit + STEP ;
}
}

Output:

Fahrenheit Celsius
0.0 -17.78
25.0 -3.89
50.0 10.00
75.0 23.89
100.0 37.78
125.0 51.67
150.0 65.56
175.0 79.44
200.0 93.33
225.0 107.22
250.0 121.11

The program prints a conversion table for reading temperature in celsius, given the fahrenheit values. The minimum and maximum values and step size are defined as symbolic constants.

These values can be changed by redefining the #define statements. An user-defined data type name REAL is used to declare the variables fahrenheit and celsius.

The formation specifications %5.1f and %7.2 in the second printf statement produces two column output as shown.

Let me know if you find any difficulty in understanding this C Program with example and I would be glad to explain it further.

Online Training Tutorials