APL/APL1.1/CM2/conversion.c

18 lines
515 B
C
Raw Normal View History

2022-01-25 14:25:17 +01:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FACTOR 2.54
int main(int argc, char* argv[]) {
double length = strtod(argv[1], NULL), new_length;
if (!strcmp(argv[2], "cm")) { /*On veut convertir en pouces*/
new_length = length / FACTOR;
printf("%1.3fcm = %1.3fin\n", length, new_length);
} else { /*On veut convertir en centimètres*/
new_length = length * FACTOR;
printf("%1.3fin = %1.3fcm\n", length, new_length);
}
return EXIT_SUCCESS;
}