I declare an int variable and use cin >> to read whole numbers: int count; cin >> count; reads values like 42, -17, or 0. The extraction stops at any non-digit character.
If the user types 42 cats, cin >> count; reads 42 and leaves cats in the buffer. If they type 3.14, it reads 3 and leaves .14 behind. This partial reading causes problems with multiple values.
When the user types invalid input like abc, the read fails and count keeps its previous value. The cin stream enters a fail state, blocking all future reads until you clear it.