Home Forums C Programming calculate and display mpg in C program Re: Re: calculate and display mpg in C program

#3493
GWILouisaxwzkla
Participant

Could do:


/****************************************************************
* File Name : c:programstempCG.cpp
* Date : December,15,2008
* Comments : new project
* Compiler/Assembler :
* Modifications :
*
*
*
*
*
* Program Shell Generated At: 2:39:00 p.m.
=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/


#include < stdio.h >
//#include < string.h >
//#include < conio.h >
//#include < math.h >
//#include < iomanip >
//#include < ctype.h >

//using namespace std;

//main function ******************************

int main ( )
{

float gallons , miles;

printf ( "Enter the gallons used (-1 to end) : " );
scanf ( "%f" , & gallons );
while ( gallons != -1 )
{
printf ( "Enter the miles driven : " );
scanf ( "%f" , & miles );
printf ( "The miles/gallon for this tank was : %f n" , miles / gallons );
printf ( "Enter the gallons used (-1 to end) : " );
scanf ( "%f" , & gallons );
}
return 0 ;
}