[URI Online Judge] – 1014 – Consumption

Calculate the average consumption of a car given the total distance traveled (in Km) and the total spent fuel (in liters).

Input

The input file contains two numbers: the first one is an integer X which represents the total distance (in Km) and the second one is an floating-point number which represents the among of spent fuel by the car, with a digit after the decimal point.

Output

Print the result which represents the medium of the car comsumptiom with 3 digits after the decimal point, followed by the message “km/l”.

Sample Input Sample Output
500
35.0
14.286 km/l
2254
124.4
18.119 km/l
4554
464.6
9.802 km/l

Solution:

#include <cstdio>

int main(){
float a, b;
scanf(“%f”, &a);
scanf(“%f”, &b);
printf(“%.3f km/l\n”, a / b);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s