Q: 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.

#include<stdio.h>
int main()

{
    float km, m, cm, f, in;     /*km=Kilometers,m=Meters,cm=Centimeters,f=Feet,in=Inch*

    printf("Enter distance in kilometers: ");

    scanf("%f", &km);

    /* formulae for distance conversion */
    m = km * 1000;
    cm = km * 1000 * 100;
    f = km * 3280.84;
    in = km * 39370.08;

    printf("\nThe 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: 5

The distance in Feet: 16404.199219
The distance in Inches: 196850.406250
The distance in Meters: 5000.000000
The distance in Centimeters: 500000.000000



Comments

Popular posts from this blog

Q: Two number are input through the keyboard into two two locations C and D. write a program to interchange the contents of C and D.

Q: Consider a currency system in which there are note of seven denominations, namely, Rs. 1, Rs. 2, Rs. 5, Rs. 10, Rs. 50, Rs. 100. if a sum of Rs. N is entered through the keyboard, write a program to compute the smallest number of notes that will combine to give Rs N.