A do
–while
statement loops as long as the while
expression is true
.
Your while
expression is
choice != 'c' || choice != 'n'
In common English, that expression means
choice
is not'c'
ORchoice
is not'n'
That statement, logically, is always true. choice
is always not one of those things.
In both English and C++, you would want to use and
/&&
in that expression.
1
solved C++ Loops forever [closed]