>When I run my program I input 1 sales figure and the program goes into a never ending loop. Why?
Because you never change this condition
while (dollars > 0)
{
>and where are all the tallies "*" beside my references coming from and why
They are coming from your loop on your fixed "Sales" array. Trace the value of "counter" through those loops and compare them to the output you are getting.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
Your while loop is fine as long as you re-prompt for the next value at the end of your loop code. In pseudo code, you want something like this
prompt "continue?"
while ("yes"){
// do stuff
prompt "continue?"
}
As for as "tracing", just start with the initial value of "counter" in your loop (which is zero) and walk it through your code mentally (or on paper if you prefer). That's all tracing is. You don't have to run through it very far to understand why you are getting the output that you are.
Ezzaral
Posting Genius
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847