Exercise 1-5

Modify the temperature conversion program to print the table in reverse order, that is, from 300 degrees to 0.

In order to print the table in reverse order, instead of initializing fahr to zero and incrementing it until it reaches 300, we can assign 300 to fahr at the beginning and decrement it until it reaches zero. This means that our condition now reads fahr >= 0.

    #include <stdio.h>
    
    /* print Fahrenheit-Celsius table */
    main()
    {
        int fahr;
    
        for (fahr = 0; fahr <= 300; fahr = fahr + 20)
        for (fahr = 300; fahr >= 0; fahr = fahr - 20)
            printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr-32));
    }