Friday

September 19, 2014

September 19, 2014

Posted by **Micael** on Tuesday, May 22, 2012 at 7:55pm.

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**, Tuesday, May 22, 2012 at 9:08pmFor 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**, Tuesday, May 22, 2012 at 9:09pmSet 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.

**Answer this Question**

**Related Questions**

Programming - Design a program in pseudocode that calculates the amount of money...

Programming - Design a program in pseudocode that calculates the amount of money...

Computer Programming - I was wondering if someone could review my pseudocode to ...

programmning code - Is this code right? Declare Integer days, counter = 1 ...

programming logic and design - whats is the output for each psuedocode sedment? ...

English - 1. While he was based on the sketches, Degas painted in his studio. 2...

programming logic and design - what is the output by each psuedocode segments ? ...

C++ - 1. while(c <= 5) { product *= c; c++; 2. while ( z > 0 ) sum = sum...

Computer Science (MATLAB) - I had a test in my computer science course in which ...

Computer Science (MATLAB) - I had a test in my computer science course in which ...