Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
a The statements like J is less than or equal to 10 in the pseudocode are called loop condition stat...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started