My task is to write a simple program that takes in an unknown amount of numbers until the sentinel value is given then proceed to give out the average. The code compiles but i doesn't give back the right results. Can someone point out what was my mistake? This is not my homework assignment i do this as a hobby.
that's because it considers 9999 a valid number.
if you'd only enter 9999, you'd get 9999.
a solution would be to check if theInput == sentinal and break if so on line 18. if you do that, you won't need to check on line 14.