Loop doesn't stop!? (C++ programming)

You must exit the loop somewhere.

if(number < 0)
   break;

Alternatively you can do this (which would be better in this case):

number = 0;
while(number >= 0)
{
    ....
}

Leave a Comment