Exercise #1.4 - Symbolic Constants

alendr · updated September 14, 2021 · C
#include <stdio.h>
/* print Fahrenheit-Celcius table 
for fahr = 0, 20, ...., 300 */
/* Using Symbolic constants: #define / name / replacement text */ 

int main() 
{
    /* int fahr, celsius; */ 
    #define LOWER 0  
    #define UPPER 300
    #define STEP 20 
                                                        
    int fahr; 
    for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
        printf("%3d %6.1f\n", fahr, (5.0/9.0) * (fahr-32)); 
} 

Comments

Please sign up or log in to contribute to the discussion.