Saturday 15 October 2011

(b) 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.


/* This program takes lenght in kilo-meters from user, converts it into meters,
centimeters, feet and inches and then shows results .*/
#include<stdio.h>
#include<conio.h>
int main ()
{
    /*delaring and initializing variables*/
    float km=0, meter=0, cm=0, feet=0, inch=0;
   
    /*prompt for input*/
    printf("Please enter the distance in 'kilo meters': ");
  
    /*taking length in kilo-meters as input*/
    scanf("%f",&km);
   
    /*calculations*/
    meter = km * 1000;
    cm = meter * 100;
    feet = meter * 3.280839895;
    inch = feet * 12;
   
    /*showing results*/
    printf("Here is the conversion of %f km",km);
    printf("\n\n      In Meters: %f m      \n\n      In Centi Meters: %f cm      \n\n      In Feet: %f feet      \n\n      In inches: %f inch     ",meter,cm,feet,inch);    

    getche();
    return 0;
   
}


7 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. So i am attached to products write-up. It truly is good for explore families verbalize at the cardiovascular system aside from awareness to achieve success critical look is invariably simply just noticed. UKdistance

    ReplyDelete
  4. Thank you very much for the sharing! COOL.. entfernung zwischen

    ReplyDelete