URI Online Judge | 1014 Consumption (Solution)

Problem Link:
https://www.urionlinejudge.com.br/judge/en/problems/view/1014

URI Online Judge | 1014

Consumption

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
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 which represents the total distance (in Km) and the second one is an floating-point number Y  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 InputSample Output
500
35.0
14.286 km/l
2254
124.4
18.119 km/l
4554
464.6
9.802 km/l
Solution:
#include<stdio.h>
int main(){
int x;
double y;
scanf("%d %lf",&x,&y);
printf("%.3lf km/l\n",(x/y));
return 0;
}

Comments

Popular posts from this blog

URI Online Judge | 1036 Bhaskara's Formula (Solution)

URI Online Judge | 1043 Triangle (Solution)

URI Online Judge | 1042 Simple Sort (Solution)