### Solutions for Skillrack CSE1001 Inlab 8

24-Oct-2016 to 5-Nov-2016

Total time : 20 mins

Challenges : 1

### QuestionÂ (Convert meters to kilometers, yards and miles)

In an Olympic competition the distance to be covered by the athlete player is given in meters. Develop an algorithm and write a C program to convert it into kilometers, yards and miles.

1 meter = 0.001 kilometers = 1.094 yards = 0.0006215 miles

(Round to four decimal places)

For example, the input is 100 meters, then output is 0.1000 kilometers, 109.4000 yards and 0.0622 miles

**Input format**

Distance in meters

**Output format**

All values must be rounded to four decimal places

Distance in kilometers

Distance in yards

Distance in miles

### Solution

#include < stdio.h > int main() { int d; float k,y,m; scanf("%d",&d); k=d*0.001; y=d*1.094; m=d*0.006215; printf("%f\n%f\n%f",k,y,m); return(0); }

### Input

INPUT: 1000

### Output

OUTPUT: 1.000000 1094.000000 6.215000

### Note

According to the number of decimal places change

printf(“%.< number of decimal places >f”,< variable >);

Advertisements