Write a c program which takes distance between two cities in k.m. a and convert it in meter,c.m.,inch and feet.










#include<stdio.h>
int main(){
    int km,meter,cm;
    float inch,feet;
    printf("Enter the distance between two cities in KM : ");
    scanf("%d",&km);
    //Conversion of km in meter
    meter = km * 1000;
    printf("\nDistance between two cities is : %d meter",meter);
    //converion of meter in centi meter
    cm = meter * 100;
    printf("\nDistance between two cities is : %d c.m.",cm);
    //Conversion of c.m. in inch
    inch = cm / 2.54f;
    printf("\nDistance between two cities is : %f inch",inch);
    //Conversion of inch in feet
    feet = inch / 12;
    printf("\nDistance between two cities is : %f feet",feet);
    return 0;
}





Alogrithm:
**




No comments: