I am having issues with while loops ( or do while loops I think is another name for them). While loops seem so easy and I feel like I get them until I have to do problems on my own.
Can anyone explain them to me?
here is a problem from my homework:
which values of b do the following algorithm terminate?
while k<5 do
Now the answer I get is that it terminates at 3
b k k<5
3 5 False (cause k cannot = 5 right?)
but the answer in the back of the book is b>(or equal to)=2.
What am I doing wrong?!?
Also I get confused when another step is added in the while loop, such as:
while k<(or equal to) 4 do
I am just not getting these. I think I may be over complicating them.
Help me uncomplicate the whole thing. Please!!!!