# C Program To Convert Kilometers to Miles

In this post, we will learn how to convert kilometers to miles using the C Programming language.

This program asks the user to enter the distance in kilometers, then it will convert the distance into miles by dividing the kilometer by 1.6.

1 Mile = 1.6 Kilometers

So, without further ado, letâ€™s begin this tutorial.

Contents

## C Program To Convert Kilometers to Miles

```// C Program to Convert Kilometers to Miles
#include <stdio.h>
int main(){
float km, miles;

printf("Enter the distance (in Km): ");
scanf("%f", &km);

// Conversion
miles = km / 1.6;

// Displaying output
printf("%.2f Kilometers = %.2f Miles", km, miles);
return 0;
}
```

Output

``````Enter the distance (in Km): 15
15.00 Kilometers = 9.38 Miles
``````

## How Does This Program Work ?

```    float km, miles;
```

In this program, we have declared two float data type variables named as km and miles.

```    // Asking for input
printf("Enter the distance (in Km): ");
scanf("%f", &km);
```

Then, the user is asked to enter the distance in kilometers.

```    // Conversion
miles = km / 1.6;
```

As we know, 1 Mile = 1.6 Kilometers, so using this we convert the distance from kilometers into miles.

```    // Displaying output
printf("%.2f Kilometers = %.2f Miles", km, miles);
```

Finally, the result is displayed to the screen using printf() function.

## Conclusion

I hope after going through this post, you understand how to convert kilometers to miles using C Programming language.

If you have any doubt regarding the program, feel free to contact us in the comment section. We will be delighted to help you.