-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdistance.c
28 lines (23 loc) · 913 Bytes
/
distance.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>
#include <conio.h>
int main()
{
float distanceInKM;
float distanceInMeters;
float distanceInFeet;
float distanceInInches;
float distanceIncentimeters;
printf("Enter a distance between two cities in KM\n");
scanf("%f", &distanceInKM);
distanceInMeters = distanceInKM * 1000;
distanceInFeet = ( distanceInKM * 1000) / 0.3048; // 1 feet = 0.3048 m
distanceInInches = (distanceInKM * 1000) * 39.3701; // 1 m = 39.3701 inches
distanceIncentimeters = distanceInKM * 1000 * 100; // 100 centimeters = 1 m
printf("Distance in KM - %f\n", distanceInKM);
printf("Distance in meters - %f\n", distanceInMeters);
printf("Distance in Feet - %f\n", distanceInFeet);
printf("Distance inInches - %f\n", distanceInInches);
printf("Distance in Centimeters - %f\n", distanceIncentimeters);
getch();
return 0;
}