In this **c program,** we will **convert distance** input by the user in meters, feet, inches, and centimeters. We will also write the algorithm of **c program to convert distance in meters, feet, inches, and centimeters**. We will firstly breakdown the problem and write an algorithm, then after that, we will write the c program and obtain the required output.

We need to take distance (in kilometers) from the user in kilometers and then convert it into meters, feet, inches, and centimeters and display as an output on the screen.

This tutorial is broke down in following parts:

Let’s write this c program to convert distance in meters, feet, inches and centimeters. But before that, let’s understand all the concept that we are gonna use in our program.

## 1. Concepts

So, we have the distance in kilometers that is input by the user and we need to display it in meters, feet, inches, and centimeters through a c program, and display them separately on the output screen.

Formula of the calculations:

```
Meter = km * 1000
Feet = km * 3280.84
Inches = km * 39370.1
Centimeter = km * 100000
```

What are the concept of c programming you need to learn before writing this program?

Kindly, learn these basic topics, before continuing and writing this C Program.

## 2. Algorithm

Here’s the algorithm of writing this C Program to convert distance in meters, feet, inches, and centimeters:

- START
- INPUT DISTANCE
- Meter = km * 1000
- Feet = km * 3280.84
- Inches = km * 39370.1
- Centimeter = km * 100000
- DISPLAY Meter
- DISPLAY Feet
- DISPLAY Inches
- DISPLAY Centimeter
- STOP

Follow the same algorithm and let’s write the actual c program.

## 3. C Program to convert distance in meters, feet, inches and centimeters

```
/* C Program to convert input distance in meter, feet, inches, centimeter */
#include <stdio.h>
#include <conio.h>
int main() {
int distance;
float meter, feet, inches, centimeter;
printf("Enter the distance [in Kilometers]: ");
scanf("%d", & distance);
meter = distance * 1000;
feet = distance * 3280.84;
inches = distance * 39370.1;
centimeter = distance * 100000;
printf("Meter = %f\n", meter);
printf("Feet = %f\n", feet);
printf("Inches = %f\n", inches);
printf("Centimeters = %f\n", centimeter);
getch();
}
```

## 4. Output

As we have written out C Program, let’s have a look at the out. We are giving input distance as 520 in kilometers and now, here are the outputs.

## 5. Resources

Here are the files of the program, you can download and try it out on your computer: