Posted by Micael on .
Set k=1
While k<=5
Display k + 1
End While
In the above what gets displayed
Set k=1
While k<=5
k = k + 2
End While
In the above how many times is the loop executed
For x = 0 To 5
Display x
End For
How many times will the above loop get executedâ€¦what will it print

Computer programming 
Kenton,
For the first question, the loop runs 5 times, just count it on your fingers. It will display 23456
For the second question, the loop runs three times. Once when k = 1, once when k = 3, and once when k = 5.
For the third question, it will either run 5 or 6 times...I am not familiar with this syntax. If the loop will run when x = 5, then 6 times. If not, then only five.
Also, if it will run when x = 5, then the output will be:
012345
otherwise, it will be:
1234
Hope this helps! 
Computer programming 
MathMate,
Set k=1
While k<=5
Display k + 1
End While
k does not get updated inside of the while loop, so it will print 2 and loop forever.
Set k=1
While k<=5
k = k + 2
End While
When it hits "while k<=5", the values of k are
1,3,5,7...
So how many times does it get executed?
For x = 0 To 5
Display x
End For
By definition of the for loop, it executes 6 times and displays the 6 integers.