March 31st, 2003, 08:02 PM
|
#1 (permalink)
|
| Junior Member
Join Date: Jul 2002
Posts: 27
| there any mistake in my programme ?
hi .. ..
#include<stdio.h>
int main( )
{
float miles, gallons, total, average, counter;
total = 0.0;
counter = 0.0;
gallons = 0.0;
miles = 0.0;
printf("Enter the gallons used (-1 TO END): ");
scanf("%f", &gallons);
printf("Enter the miles driven: ");
scanf("%f", &miles);
while( gallons != -1)
{
counter ++;
total = miles / gallons + total;
printf("Enter the gallons ( -1 to end): ");
scanf("%f", &gallons);
printf("Enter the miles: ");
scanf("%f", &miles);
}
if(counter != 0)
{
average = total / counter;
printf("The overall average was %f",average);
}
else
printf("\n no gallons entered");
return 0;
}
i will wait your reply. 
__________________
keep smile,,,
the life is short,,,
|
| |