#include <stdio.h>
#define CONVERSION 1000
int main() {
char dataType;
float input = 0;
float output = 0;
printf("Please enter the input data type. K or k for kilometers, M or m for meters\n");
scanf("%c", &dataType);
printf("Please enter the value to convert\n");
scanf("%f", &input);
if (dataType == 'k' || dataType == 'K') {
output = input * CONVERSION;
}
else if (dataType == 'm' || dataType == 'M') {
output = input / CONVERSION;
}
printf("%f\n", output);
return 0;
}
Comments