# C Program to Convert Kilometer to Miles

• Write a C program to convert distance from kilometers to miles.

This program takes distance in kilometer(km) as input from user and convert it to Miles and prints it on screen. Here we are using Miles to Kilometer conversion factor of 1.6093, that means one mile is equal to 1.6093 kilometers.

### C program to convert Kilometer to Miles

/*
* C program to convert Kilometer to Miles
*/
#include<stdio.h>
#include<conio.h>

int main() {
float MILEKM = 1.6093, FEETMETER = 3.2808;
float km, meter = 0, feet, mile = 0;
int m;

printf("Enter the distance in kilometer\n");
scanf("%f", &km);

mile = km/MILEKM;
printf("%.2fKm is equal to %.2f Mile OR \n", km, mile);
mile = 0;

if (km >= MILEKM) {
while (1) {
mile++;
km = km - MILEKM;
if (km < MILEKM)
break;
}

}

/* kilometer to meter conversion */
meter = km * 1000;
m = (int)meter;
meter -= m;
/* Meter to Feet conversion */
feet = meter * FEETMETER;

/* print the output */
printf("%.2f miles, %d meter and %.2f feet\n",
mile, m, feet);

getch();
return 0;
}

Program Output

Enter the distance in kilometer
40
40.00Km is equal to 24.86 Mile OR
24.00 miles, 1376 meter and 2.63 feet