
please wait
|
|
while(!done)
was evaluating itself to false immediately and skipping the input. Then your default zeros you put for the input values d and e.
|
|
I'm guessing this was some type of homework assignment to calculate with loops, yes? You had one overarching issue which was not resetting the values before you used them later in a different context. When you used your done boolean, it became true after the first loop, but you never reset it to false before you try to take the input for your product calculation. So, what was happening was the program was completely skipping lines 57-69 because your while(!done) was evaluating itself to false immediately and skipping the input. Then your default zeros you put for the input values d and e. Also take a look at the starting and ending values for your second loop. Do you want and inclusive range or exclusive? Meaning, if I say whats the range between 1 and 5 and your program returns 5 because it counted 1,2,3,4, and 5. That means that range would be inclusive. If you wanted exclusive you would get 3 because your range would be counting only the numbers between your end two numbers, not the end numbers themselves. For example, if you want the exclusive range of 1-5 it would count the 2,3, and 4 but not 1 and 5. Your answer is 3 with that kind of a range. Figure out whichever one you're looking for and adjust your values to match. You seem to have a pretty good grasp on this already!
Edit & Run |