Distance Converter Program(Ref: Let us c-chapter1)
This program converts the entered value into meters,feet,inches and centimeters
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>
/*
1 kilometer=39370 inches
1 kilometer=3281 Feet
1 kilometer=100000 centimeters
1 kilometer=1000 meters
*/
void main()
{
float km,meter,feet,inches,centimeter;
clrscr();
printf("Enter the distance between two cities:");
scanf("%f",&km);
meter=1000*km;
centimeter=100000*km;
inches=39370*km;
feet=3281*km;
printf("\nThe Entered distance between two cities in meter is:%f",meter);
printf("\nThe Entered distance between two cities in centimeter is:%f",centimeter);
printf("\nThe Entered distance between two cities in inches is:%f",inches);
printf("\nThe Entered distance between two cities in feet is:%f",feet);
getch();
}
This program converts the entered value into meters,feet,inches and centimeters
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>
/*
1 kilometer=39370 inches
1 kilometer=3281 Feet
1 kilometer=100000 centimeters
1 kilometer=1000 meters
*/
void main()
{
float km,meter,feet,inches,centimeter;
clrscr();
printf("Enter the distance between two cities:");
scanf("%f",&km);
meter=1000*km;
centimeter=100000*km;
inches=39370*km;
feet=3281*km;
printf("\nThe Entered distance between two cities in meter is:%f",meter);
printf("\nThe Entered distance between two cities in centimeter is:%f",centimeter);
printf("\nThe Entered distance between two cities in inches is:%f",inches);
printf("\nThe Entered distance between two cities in feet is:%f",feet);
getch();
}
No comments:
Post a Comment