Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write psuedocode for the following scenarios using the appropriate loops: While

ID: 3902428 • Letter: W

Question

Write psuedocode for the following scenarios using the appropriate loops:

While loop:

Repeatedly print the value of the variable xValue, decreasing it by 0.5 each time, as long as xValue remains positive.

For loop:

Print the square roots of the first 25 odd positive integers.

For square root, you can just call a function like "sqrt(<number/variable you want square root of>)" or something similar. Remember pseudocode is more about the problem solving idea than the format (thought that needs to be somewhat proper as well); so as long as you have something that indicates you are getting the square root, that is fine.

Your choice of loop!

Repeats a block of code as long as the user indicates they want it to.

Explanation / Answer

WHILE LOOP:

Read xValue
while (xValue>0)
DO
print xValue
xValue=xValue-0.5
ENDWHILE

FORLOOP :

for i=1 to 25 increment by 2
DO
x=sqrt(i)
print x
ENDFOR

YOUR CHOICE OF LOOP:
while(TRUE)
DO
print "Do you want to proceed again ?"
Read in CHOICE
if CHOICE is "NO" then
Break While LOOP
else
Continue While LOOP