Convert Kilometer To Meter, Centimeter, Millimeter: C Program

The distance between two cities (in Kilometer) is input through the keyboard. Write a program to convert and print this distance in meters, centimeter, millimeter.

Note:
1 Kilometer(km) = 1000 Meters(m).
1 Kilometer(km) = 100000 Centimeters(cm).
1 Kilometer(km) = 1000000 Millimeters(mm).

For n Kilometers(KM)
n Kilometer = n * 1000 Meters
n Kilometer = n * 100000 Centimeters
n Kilometer = n * 1000000 Millimeters

Convert Kilometer To Meter, Centimeter, Millimeter: C Program



YouTube Link: https://www.youtube.com/watch?v=zj79Yj0-ctI [Watch the Video In Full Screen.]


Source Code: Convert Kilometer To Meter, Centimeter, Millimeter: C Program

#include < stdio.h >

int main()
{
    float km, cm, mm, m;

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

    m  = km * 1000.0;
    cm = km * 100000.0;
    mm = km * 1000000.0;

    printf("Distance in Meter is %f\n", m);
    printf("Distance in Centimeter is %f\n", cm);
    printf("Distance in Milimeter is %f\n", mm);

    return 0;
}

Output 1:
Enter distance in Kelometer
10
Distance in Meter is 10000.000000
Distance in Centimeter is 1000000.000000
Distance in Milimeter is 10000000.000000

Output 2:
Enter distance in Kelometer
5
Distance in Meter is 5000.000000
Distance in Centimeter is 500000.000000
Distance in Milimeter is 5000000.000000

Prefix Symbol Multiply by
yotta Y 1024
zetta Z 1021
exa E 1018
peta P 1015
tera T 1012
giga G 109
mega M 106
hectokilo hk 105
myria ma 104
kilo k 103
hecto h 102
deka da 101
UNIT 1 100
deci d 10-1
centi c 10-2
milli m 10-3
decimilli dm 10-4
centimilli cm 10-5
micro µ 10-6
nano n 10-9
pico p 10-12
femto f 10-15
atto a 10-18
zepto z 10-21
yocto y 10-24

For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List

For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert