View Single Post
Old March 31st, 2003, 08:02 PM   Digg it!   #1 (permalink)
has2
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,,,
has2 is offline   Reply With Quote
Search TechIMO for Answers: