Q2 The distance between two cities (in km.) is input through the keyboard. Write a program to convert and print this distance in meters, feet, inches and centimeters.

Let Us C Solutions 2

Program: 52

Write a program to convert the distance from km to m,cm,feet and inches. | Let Us C Solutions

 

#include<stdio.h>
int main()
{
    float km, m, cm, f, in;
    printf("Enter distance in kilometers: ");
    scanf("%f",&km);
    /* Calculate the conversion */    m = 1000 * km;
    cm = 1000 * 100 * km;
f = 3280.84 * km;
in = 39370.08 * km; printf("The distance in Feet: %f\n", f); printf("The distance in Inches: %f\n", in); printf("The distance in Meters: %f\n", m); printf("The distance in Centimeters: %f\n", cm);    
return (0); }

Output:

Enter distance in kilometers: 2 
The distance in Feet: 6561.680176
The distance in Inches: 78740.156250
The distance in Meters: 2000.000000
The distance in Centimeters: 200000.000000

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.