when i input zero the program will reset how can i stop that from happenning, and when i compile my program the (Avg cost/lb) is giving me (-1.#J) what is this crap!! Also how can i improve this program to be more bullet.
when i input zero the program will reset how can i stop that from happenning, and when i compile my program the (Avg cost/lb) is giving me (-1.#J) what is this crap!! Also how can i improve this program to be more bullet.
Last edited by joker_tony; 03-27-2008 at 11:07 PM.
Well, run is 0, i is 0; what do you expect 0/0 to print?
i think it should be error
oh yea i get it now how can i change that
i dont know what to do also how come when i type in a garbage string i will read the first letter. i want it to read everything. also is tehre a way to change that
well, i have to print that line because its an assigment
i thnink i should change it to scanf("%s") to read the string. also maybe if i put a loop on avg it may work saying if its zero to ask to input a number again. or something like that
You can't loop on avg, since it's computed from a through h. Consider: right after you hit r, everything gets zeroed out; you don't want the user to enter a number somewhere. If this is an assignment, then your instructor (should have) gave you guidelines that should tell you what to print when the average doesn't exist.
is there any way to fix it
fix the line of the garbage output becuase when the proffesor had compile his program his values were set to zero
What do you mean? Do you mean he printed 0 for the average? Then check for i=0, and print 0 instead of calculating the average.