/ ..
Fahrenheit Converter

I am currently learning C and i would like to share my first “proper” program.
It’s not much, but regardless i am quite happy with this.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>

int celsius(int fahrenheit)
{
    return 5 * (fahrenheit - 32) / 9;
}

int main(int argc, char *argv[])
{
    if (argc >= 2) {
        int fahrenheit = atoi(argv[1]);
        printf("%d°F is equal to %d°C\n",
               fahrenheit, celsius(fahrenheit));
        return EXIT_SUCCESS;
    }
    printf("Not enough arguments supplied.\n");
    printf("Usage:\tcelsius <degrees fahrenheit>\n");
    return EXIT_FAILURE;
}