Issue
I seem to have gotten myself into an infinite while-loop:
while(number != 0){
if(number % 2= != 0{
numberState[1]++;
}
else numberState[0]++;
}
The program should be able to count the amout of even and odd numbers using arrays. when I input 0 it should stop but for some reason it doesnt eventhough the while-loop states that the input has to be different than 0. Can anyone help me with this?
Solution
You need to change either the variable you check in your while condition or the variable you manipulate in the while loop.
Currently you're expecting number
to change and become zero.
Answered By - Jonathan M. Hethey