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

  1. #include <stdio.h>
  2. #define LITERS_PER_GALLON 3.786
  3. #define KM_PER_MILE 1.609
  4. int main (void) {
  5. float miles;
  6. float gallons;
  7. printf("Miles traveled: ");
  8. scanf("%f", &miles);
  9. printf("gasoline gallons: ");
  10. scanf("%f", &gallons);
  11. printf("Miles per gallon: %.1f\n", miles / gallons);
  12. printf("Liters per 100km: %.1f\n", (gallons * LITERS_PER_GALLON)/(miles * KM_PER_MILE));
  13. return 0;
  14. }