I need to write a program that input the miles driven and gallons used . The program should calculate and display the miles per gallon. After processing all input information, the program should calculate and print the combined miles per gallon obtain for all tankful.
Here what i got so far
#include <stdio.h>
int main()
{
int num1,num2,miles/gallon,Avgmile/gallon;
printf("Enter the gallons used\n");
scanf("%d",num1);
while (num1>=-1) {
printf("Enter miles driven\n");
scanf("%d",num2);
miles/gallon=(num1/num2);
printf("Miles per gallon is %d\n", miles/gallon);
}
while (num1<=-1) {
Avgmile/gallon=??????? /*no idea what this should be*/
printf("Avgmile/gallon is %d", Avgmile/gallon);
}
return 0;
}
Run result shoud be something like this..
Enter the gallon used (-1 to end): 12.8
Enter the miles driven:287
The miles/gallon for this tank was 22.421875
Enter the gallon used (-1 to end): 10.3
Enter the miles driven:200
The miles/gallon for this tank was 19.417475
Enter the gallons used (-1 to end): -1
Overall average miles/gallon was 20.919675
Please help me i have no idea how to write this program