Home › Forums › C Programming › calculate and display mpg in C program › Re: Re: calculate and display mpg in C program
December 15, 2008 at 7:59 pm
#3493
GWILouisaxwzkla
Participant
Could do:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | <br /> /****************************************************************<br /> * File Name : c:programstempCG.cpp<br /> * Date : December,15,2008<br /> * Comments : new project<br /> * Compiler/Assembler :<br /> * Modifications :<br /> *<br /> *<br /> *<br /> *<br /> *<br /> * Program Shell Generated At: 2:39:00 p.m.<br /> =-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/<br /> <br /> <br /> #include < stdio.h ><br /> //#include < string.h ><br /> //#include < conio.h ><br /> //#include < math.h ><br /> //#include < iomanip ><br /> //#include < ctype.h ><br /> <br /> //using namespace std;<br /> <br /> //main function ******************************<br /> <br /> int main ( )<br /> {<br /> <br /> float gallons , miles;<br /> <br /> printf ( "Enter the gallons used (-1 to end) : " );<br /> scanf ( "%f" , & gallons );<br /> while ( gallons != -1 )<br /> {<br /> printf ( "Enter the miles driven : " );<br /> scanf ( "%f" , & miles );<br /> printf ( "The miles/gallon for this tank was : %f n" , miles / gallons );<br /> printf ( "Enter the gallons used (-1 to end) : " );<br /> scanf ( "%f" , & gallons );<br /> }<br /> return 0 ;<br /> }<br /> <br /> <br /> <br /> |