c++ stream infinite loop, infinite loop problem c++, c++ infinite loop, cin
make infinite loop c++, infinite while loop c++, how to stop an infinite loop in c++,
c++ cin infinite loop
make infinite loop c++, infinite while loop c++, how to stop an infinite loop in c++,
c++ cin infinite loop
Consider the condition in the while structure that
is (number<=upperLimit) and in the while block the value of number is
changing (number = number + 1) to ensure that the condition is tested again
next time. If it is true, the while block is executed and so on. So in the
while block statements, the variable used in condition must change its value so
that we have some definite number of repetitions. What will happen if we do not
write the statement number = number + 1; in our program? The value of number
will not change, so the condition in the while loop will be true always and the
loop will be executed forever. Such loops in which the condition is always true
are known as infinite loops as there are infinite repetitions in it.
Tips:
Always use the self explanatory variable names
Practice a lot. Practice makes a man perfect.
While loop may execute zero or more times.
Make sure that loop test (condition) has an
acceptable exit.
No comments:
Post a Comment