Language C
Description Calculate the miles per gallon a car gets given the gallons of gas used and the total miles driven. Assume the car holds 15 gallons of gas and travels a total of 350 miles on a full tank. The formula for miles per gallons (MPG) is given by total miles driven/total gallons used. We know the answer should be 23.33 mpg. Your output should be 1 line: the car gets xxx miles per gallon.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
    float gallons_of_gas, miles_per_gallon, miles_traveled;
    gallons_of_gas=15;
    miles_traveled=350;
    miles_per_gallon=gallons_of_gas/miles_traveled;
    printf ("Value of gallons of gas: %g\n", gallons_of_gas);
    printf ("Value of miles per gallon: %g\n", miles_per_gallon);
    printf ("Value of miles traveled: %g\n", miles_traveled);
    putchar ('\n');
    system ("pause");
    return EXIT_SUCCESS;
}