Question: 7. Below is a simple while loop written in pseudocode. (In this pseudocode, the body of the loop is denoted by indentation.) Set J

7. Below is a simple while loop written in pseudocode. (In this

 

7. Below is a simple while loop written in pseudocode. (In this pseudocode, the body of the loop is denoted by indentation.) Set J to 1 While (J is less than or equal to 10) Print J Add 1 to J Print J a. In the above pseudocode, what does the book call statements like J is less than or equal to 10? Hint: these statements follow while, and must unambiguously evaluate to true or false. b. Run through the algorithm by playing computer. What value is printed by the final "Print J" instruction? c. Make a version of the algorithm with the "Add" instruction line is omitted - what is the term for the kind of loop that has just been created? d. Make another version of the algorithm were you remove the last "Print instruction. Then, change the algorithm so that inside the loop it prints the even integers in the range 2 through 6 inclusively. e. In the modified version 7d above, bring back the final "Print "instruction. Now, run the algorithm and determine what will be printed by the final "Print instruction?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

a The statements like J is less than or equal to 10 in the pseudocode are called loop condition stat... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!