#include /* * This program takes a volume in gallons and converts the quantity to several * other volume units, finally liters. */ int main() { // Ask for the quantity. printf("Please enter a volume in gallons: "); double gal; scanf("%lf", &gal); // A gallon is defined as 231 cubic inches. So let's convert. int cuin_per_gal = 231; double cuin = cuin_per_gal*gal; printf("%g = %g cubic inches.\n", gal, cuin); // An inch is defined as 2.54 centimeters. So on we go. double cm_per_in = 2.54; // Centemeters per inch. double cc = cuin * cm_per_in * cm_per_in * cm_per_in; printf(" = %g cubit centimeters\n", cc); // A cc is the same as a ml, so we can get liters. printf(" = %g liters\n", cc / 1000.0); }