“Sometimes it is the people no one can imagine anything of who do the things no one can imagine.” ― Sir Alan Turing


ADS

ADS

Tuesday, March 28, 2017

URI - 1014 Consumption || Solution in C / C++


Calculate a car's average consumption being provided the total distance traveled (in Km) and the spent fuel total (in liters).

Input

The input file contains two values: one integer value representing the total distance (in Km) and the second one is a floating point number Y  representing the spent fuel total, with a digit after the decimal point.

Output

Present a value that represents the average consumption of a car with 3 digits after the decimal point, followed by the message "km/l".
Input SampleOutput Sample
500
35.0
14.286 km/l
2254
124.4
18.119 km/l
4554
464.6
9.802 km/l

SOURCE CODE

#include <stdio.h>

int main() {
  int x;
  float y, d;

  scanf("%d %f", & x, & y);

  d = (x / y);

  printf("%0.3f km/l\n", d);

  return 0;
}

No comments:

Post a Comment