/** * Convert US mpg to European liters / 100km * From the command line!! * @author gtowell * Created: Feb 2021 * **/ #include #include // needed for atof #define GALLONS_PER_LITER 0.2641 #define KILOMETERS_PER_MILE 1.609 int main(int argc, char const *argv[]) { if (argc < 2) { printf("Usage: %s number\n", argv[0]); printf(" where: number is a US style MPG estimate\n"); return 0; } double mpg = atof(argv[1]); double lp100km = (1 / mpg) * (1 / GALLONS_PER_LITER) * (1 / KILOMETERS_PER_MILE) * 100; printf("%5.2f liters per 100km \n", lp100km); return 0; }