Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 573 Bytes

exercise1-5.md

File metadata and controls

26 lines (19 loc) · 573 Bytes

Exercise 1-5

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

Process

Same temperature conversion program as previous program, but using for loop and in reverse

Final Code

#include <stdio.h>

int main(){
    int fahr;

    for(fahr = 300; fahr >= 0; fahr = fahr - 10) {
        printf("%3d\t%6.1f\n", fahr, (5.0/9.0) * (fahr - 32) );
    }
}

Output

output for exercise1-5

Back to Main