An algorithm will: • output each integer value between 100 and 200 that ends with the digit 7, for example, 107 • output a final count of the number of values that are output. Write pseudocode for this algorithm. Any variables used must be declared.
- (a)An algorithm will: • output each integer value between 100 and 200 that ends with the digit 7, for example, 107 • output a final count of the number of values that are output. Write pseudocode for this algorithm. Any variables used must be declared.[5]
- (b)Study the following pseudocode. CASE OF MySwitch 1: ThisChar ← 'a' 2: ThisChar ← 'y' 3: ThisChar ← '7' OTHERWISE: ThisChar ← '*' ENDCASE Write pseudocode with the same functionality without using a CASE structure.[4]
Mark scheme
Marking points from the official mark scheme (May/June 2022). The mark or mark type is shown in brackets.
- [5] (a) DECLARE ThisInt, Count : INTEGER Count ← 0 FOR ThisInt ← 100 TO 200 IF ThisInt MOD 10 = 7 THEN OUTPUT ThisInt Count← Count + 1 ENDIF NEXT ThisInt OUTPUT Count
- [5] (a) Mark as follows: 1 Declare loop variable and counter as integers, counter initialised
- [5] (a) Mark as follows: 2 Loop 100 to 200, no step defined
- [5] (a) Mark as follows: 3 Test value in a loop
- [5] (a) Mark as follows: 4 Output selected value and incrementing a counter in a loop
- [5] (a) Mark as follows: 5 Output the counter, following a reasonable attempt, after the loop
- [5] (a) Alternative Solution: DECLARE ThisInt, Count : INTEGER Count ← 0 FOR ThisInt ← 107 TO 197 STEP 10 OUTPUT ThisInt Count← Count + 1 NEXT ThisInt OUTPUT Count
- [5] (a) Mark as follows: 1 Declare loop variable and counter as integers,, counter initialised
- [5] (a) Mark as follows: 2 Loop (107 to 197)
- [5] (a) Mark as follows: 3 STEP 10 or explicit increment if conditional loop used
- [5] (a) Mark as follows: 4 Output each value and incrementing a counter in a loop
- [5] (a) Mark as follows: 5 Output the counter, following a reasonable attempt, after the loop
- [4] (b) IF MySwitch = 1 THEN ThisChar ← 'a' ELSE IF MySwitch = 2 THEN ThisChar ← 'y' ELSE IF MySwitch = 3 THEN ThisChar← '7' ELSE ThisChar ← '*' ENDIF ENDIF ENDIF
- [4] (b) Mark as follows: 1. ANY test of MySwitch = 1, 2 or 3
- [4] (b) Mark as follows: 2. All three comparisons and corresponding assignments
- [4] (b) Mark as follows: 3. OTHERWISE, or initial assignment of default value
- [4] (b) Mark as follows: 4. Completely correct IF...THEN...ELSE...ENDIF syntax
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →