Question: #define _ CRT _ SECURE _ NO _ WARNINGS #include #include int main ( ) { const float EXIT _ VAlUE = - 1 .
#define CRTSECURENOWARNINGS
#include
#include
int main
const float EXITVAlUE f;
float gallons;
int miles;
float tankful;
printfEnter the gallon used f to end EXITVAlUE;
scanff &gallons;
while gallons EXITVAlUE
if gallons
while gallons EXITVAlUE && gallons
printfYou entered an invalid value
;
printfEnter the gallon used f to end EXITVAlUE;
scanff &gallons;
while gallons EXITVAlUE
printfEnter the miles driven: ;
scanfd &miles;
while miles
printfYou entered an invalid value
;
printfEnter the miles driven: ;
scanfd &miles;
tankful miles gallons;
printfThe milesgallons for this tankful was f tankful;
printfThats all folks, enter any key to exit";
The above is my code for this question, but this code has infinity loop and never ends. NOT using continue or break statement, how can I rewrite my code to make it work?
Gas Mileage Drivers are concerned with the mileage obtained by their automobiles.
One driver has kept track of several tankfuls of gasoline by recording miles
driven and gallons used for each tankful Develop a program that uses scanf to input
the miles driven and gallons used for each tankful The program should calculate and
display the miles per gallon obtained for each tankful After processing all input information,
the program should calculate and print the combined miles per gallon obtained
for all tankfuls
This code is in C language.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
