Learning by doing: Reading books and trying to understand the (code) examples
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

23 lines
406 B

#include <stdio.h>
#define LITERS_PER_GALLON 3.786
#define KM_PER_MILE 1.609
int main (void) {
float miles;
float gallons;
printf("Miles traveled: ");
scanf("%f", &miles);
printf("gasoline gallons: ");
scanf("%f", &gallons);
printf("Miles per gallon: %.1f\n", miles / gallons);
printf("Liters per 100km: %.1f\n", (gallons * LITERS_PER_GALLON)/(miles * KM_PER_MILE));
return 0;
}