assignment
#include<stdio.h>
#include<conio.h>
#include <stdlib.h>
int main(){
float gallons[5];
int x;
int miles[5];
int totalM = 0;
float total = 0;
float totalN=0;
float ave;
for(x=0 ;x<5;x++){
printf("\nEnter Gallons used(-1 to end): ");
scanf("%f",&gallons[x]);
if(gallons[x] == -1){
break;//exit
}
printf("Enter Miles Driven: ");
scanf("%d",&miles[x]);
// summation
totalM += miles[x];
totalN += gallons[x];
total = miles[x] / gallons[x];
ave = totalM / totalN;
printf("\nThe Miles / gallon for this tank was %.6f\n",total);
}// end of loop
printf("\nThe Overall average miles/gallon was %.6f",ave);
getch();
}
