about summary refs log tree commit diff stats
path: root/1.2.c
blob: f68573f244d2c05eafcdd75f6297103ad5868aa4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <stdio.h>
#include <stdlib.h>

#define LOWER 0
#define UPPER 300
#define STEP  20

float fahr_to_cel (float fahr);

int main() {
    float fahr;
    size_t fahrs;
    void *fahrp;
    fahrs = sizeof(float);
    fahrp = malloc(fahrs);
    fahr = 0;
    printf("value:%f size:%d pointer: %p\n", fahr, fahrs, fahrp);

    printf("%3s\t%6s\n", "F", "C");
    for (fahr=UPPER; fahr >= LOWER; fahr -= STEP) {
        printf("%3.0f\t%6.2f\n", fahr, fahr_to_cel(fahr));
    }
    free(fahrp);
    return 0;
}

float fahr_to_cel (float fahr) {
    return 5.0 * (fahr - 32.0) / 9.0;
}