Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 909 Bytes

exercise1-4.md

File metadata and controls

36 lines (27 loc) · 909 Bytes

Exercise 1-4

Write a program to print the corresponding Celsius to Fahrenheit table

Process

Just continued on from the previous exercise, nothing complicated really..

Final Code

#include <stdio.h>

main() {
    float celcius, fahrenheit;

    int max = 300;	/* upper limit of conversion */
    int min = 0;	/* lower limit of conversion */
    int step = 10;	/* step value of conversion */

    celcius = min; /* initialise NOTE: float conversion implicit */

    printf("\nTitle:\tCelcius to Fahrenheit conversion program\n");
    printf("Date:\t29 Sep 2021\n");

    while (celcius <= max) {
        fahrenheit = (celcius / (5.0 / 9.0)) + 32;
        printf("%3.0f\t%6.1f\n", celcius, fahrenheit);
        celcius = celcius + step;
    }
}

Output

output for exercise1-4

Back to Main