Temperature Conversion Problem is Here!

Program
       
   #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.


0 Comment "Temperature Conversion Problem is Here!"

Post a Comment

Please Post valuable Feedback...