Temperature conversion problem

Program 6) This program converts the given temperature in fahrenheit to celsius using the following conversion formula:
                             C = F- 32 / 1.8

                                                  PROGRAM
#define  F_LOW       0
#define  F_MAX     250
#define  STEP           25

main( )
 {
         typedef float REAL ;a
         REAL fahrenheit Celsius\n\n") ;
         while( farenheit <= F_MAX )
          {
                  celsius = (fahrenheit - 32.0) / 1.8 ;
               printf(" %5.1f %7.2f\n", fahrenheit, celsius);
                 fahrenheit = fahrenheit + STEP ;
          }
          getch() ;
 }     

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 userdefined data types 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. 

No comments:

Post a Comment