home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / ctutor2.zip / TEMPCONV.C < prev    next >
Text File  |  1989-11-10  |  2KB  |  55 lines

  1.                                        /* Chapter 3 - Program 8 */
  2. /****************************************************************/
  3. /*                                                              */
  4. /*     This is a temperature conversion program written in      */
  5. /*      the C programming language. This program generates      */
  6. /*      and displays a table of farenheit and centigrade        */
  7. /*      temperatures, and lists the freezing and boiling        */
  8. /*      of water.                                               */
  9. /*                                                              */
  10. /****************************************************************/
  11.  
  12. main()
  13. {
  14. int count;        /* a loop control variable               */
  15. int farenheit;    /* the temperature in farenheit degrees  */
  16. int centigrade;   /* the temperature in centigrade degrees */
  17.  
  18.    printf("Centigrade to Farenheit temperature table\n\n");
  19.  
  20.    for(count = -2;count <= 12;count = count + 1){
  21.       centigrade = 10 * count;
  22.       farenheit = 32 + (centigrade * 9)/5;
  23.       printf("  C =%4d   F =%4d  ",centigrade,farenheit);
  24.       if (centigrade == 0)
  25.          printf(" Freezing point of water");
  26.       if (centigrade == 100)
  27.          printf(" Boiling point of water");
  28.       printf("\n");
  29.    } /* end of for loop */
  30. }
  31.  
  32.  
  33.  
  34. /* Result of execution
  35.  
  36. Centigrade to Farenheit temperature table
  37.  
  38.    C = -20   F =   -4
  39.    C = -10   F =   14
  40.    C =   0   F =   32   Freezing point of water
  41.    C =  10   F =   50
  42.    C =  20   F =   68
  43.    C =  30   F =   86
  44.    C =  40   F =  104
  45.    C =  50   F =  122
  46.    C =  60   F =  140
  47.    C =  70   F =  158
  48.    C =  80   F =  176
  49.    C =  90   F =  194
  50.    C = 100   F =  212   Boiling point of water
  51.    C = 110   F =  230
  52.    C = 120   F =  248
  53.  
  54. */
  55.