RunestoneComponents icon indicating copy to clipboard operation
RunestoneComponents copied to clipboard

Misprint in CS Principles: Big Ideas in Programming Question e24_2_7

Open pdostertGSSM opened this issue 2 years ago • 1 comments

Book: CS Principles: Big Ideas in Programming Assignment: CSPPracticeQuestions / exam24_2 Question: e24_2_7

Consider the following code snippet that takes a positive integer ‘n’ as input and answer the question that follows

i <- 1 REPEAT UNTIL i ≤ n IF i MOD 2 = 1 DISPLAY(“ODD”) ELSE DISPLAY(“EVEN”) i <- i + 1 Which of the following statements are true?

I. “ODD” is printed n/2 times if n is even II. “ODD” is printed (n + 1)/2 times if n is odd III. “EVEN” is printed (n - 1)/2 times if n is odd A. I, II only B. II, III only C. I only D. I, II, III

Issue is REPEAT UNTIL i ≤ n. So keep going until i is less than or equal to n. But i starts at 1. n is a positive integer. i is less than or equal to n to start, so the loop would never execute. It would print nothing. Perhaps they want "REPEAT UNTIL i>n" but without a >= or >, problem doesn't make a whole lot of sense.

pdostertGSSM avatar Apr 21 '22 13:04 pdostertGSSM

Thanks for reporting this. It will be fixed on Saturday.

barbarer avatar Apr 22 '22 19:04 barbarer