Difference between revisions of "2018 New Spec"
(Created page with "=Question 3= The algorithm, represented using pseudo-code in Figure 2, outputs a series of numbers. The contents of the series depends on the initial value entered by the user...") |
(No difference)
|
Latest revision as of 13:54, 4 December 2018
Question 3
The algorithm, represented using pseudo-code in Figure 2, outputs a series of numbers. The contents of the series depends on the initial value entered by the user.
Figure 2
Number ← 0 WHILE (Number < 1) OR (Number > 10) OUTPUT "Enter a positive whole number: " INPUT Number IF Number > 10 THEN OUTPUT "Number too large." ELSE IF Number < 1 THEN OUTPUT "Not a positive number." ENDIF ENDIF ENDWHILE c ← 1 FOR k ← 0 TO Number – 1 OUTPUT c c ← (c * (Number - 1 – k)) DIV (k + 1) ENDFOR
The DIV operator calculates the result of an integer division, for example, 10 DIV 3 = 3. What you need to do:
Task 1
Write a program to implement the algorithm in Figure 2.
Task 2
Test the program by showing the result of entering:
- -3
- then 11
- then 10