# C Program to Convert Meters To Kilometers

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

As we know, 1000 meters = 1 Kilo meter. So, to convert the distance from meters into kilo meters, we have to divide the value of meters by 1000. This will give us the distance in kilometers.

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

## C Program to Convert Meters To Kilometers

```// C Program To Convert Meters To Kilo meters
#include <stdio.h>
int main(){
float m, km;

printf("Enter the distance (in meters): ");
scanf("%f", &m);

// Conversion Meters into Kilo meters
km = m / 1000;

// Displaying output
printf("%.2f meters = %.2f Kilo meters", m, km);
return 0;
}
```

Output

``````Enter the distance (in meters): 2700
2700.00 meters = 2.70 Kilo meters``````

## How Does This Program Work?

```    float m, km;
```

In this program, we have declared two variables named m and km.

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

Then, the user is asked to enter the value of meters.Â  This value will get stored in m named variable.

```    // Conversion Meters into Kilo meters
km = m / 1000;
```

Now, we convert the distance from meters into kilo meters by dividing the meter by 1000.

```    // Displaying output
printf("%.2f meters = %.2f Kilo meters", m, km);
```

Finally, the result is printed on the screen using printf() function. Here, we have used %.2f format specifier because we want to display the result only till 2 decimal places.

## Conclusion

I hope after going through this post, you understand how to convert meters into kilometers 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.