c-first-steps

a C playground
Index Commits Files Refs README
   1 /*    Exercise 1-5 - prints a table with degrees conversion    
   2     from bigger to lower    */
   3 
   4 #include <stdio.h>
   5 
   6 /*    Celsius values;    */
   7 #define LOWER 0        /* Celsius start number */
   8 #define UPPER 50    /* Celsius max number */
   9 #define STEP 2        /* Step between Celsius numbers    */
  10 
  11 
  12 int main (void)
  13 {
  14     float c, f;
  15 
  16     printf("Celsius to Fahrenheit\n\n");
  17 
  18     for(c = upper; c >= lower; c -= step) { 
  19         f = (c * 9.0) / 5.0 + 32;
  20         printf("%5.1f°C = %5.1f°F\n", c, f);
  21     }
  22 
  23     return 0;
  24 }