1. ## whileloop/running total problem

hi i have been asked to input 2 integers, a drivers MILES and LITRES of fuel they have used.. i am then meant to printf the miles per litre for that specific entry AND a running total of the combined MPL's added so far...

Code:
```#include <stdio.h>

int main( )
{
int miles;
int litres;
int tanks;
int mpl;
int totalmpl;
int counter;

while ( miles > 0, counter++ ) {
printf("please enter the amount of miles you have driven, alternatavely, press 0 to finish the script.\n");
scanf("%d", &miles);

printf("please enter the amount of litres you used\n");
scanf("%d", &litres);

mpl=miles/litres;

printf("the number of miles per litre you have gained is:%d\n", mpl);

while (counter > 1)
{
totalmpl=mpl+mpl;
printf("the total running miles per litre is:%d\n", totalmpl);
}
}
return 0;

}```
this outputs nothing, if anyone can help i would be delighted. THANKS

2. FYI: You code has no running total in it.

Code:
`totalmpl=mpl+mpl;`
With the idea that you want a running total.

Code:
`totalmpl=totalmpl+mpl;`
Edit: Your code makes little sense to me.

Code:
`while (counter > 1)`
Is there any reason to believe the value of counter is changing inside the loop?
I say no, therefor the loop will never run or be endless!

Tim S.

3. while ( miles > 0, counter++ )
Since miles is uninitialized at this point, it is just as likely to be negative as positive. You need to initialize it to 1 or something first. The same is even more true for counter, altho I actually don't see counter as serving any useful purpose here. Just add mpl to total (total should be initialized to 0 -- that's three uninitialized variables that need to be, tch) and get rid of counter.