Question #39123

program that will convert kilometer to meter and meter to kilometer
1

Expert's answer

2014-02-11T09:31:48-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS