An algorithm is designed to generate and output two unique random integers. Each integer value is between -10 and 10 inclusive. If both integers output are negative, a third random integer between 30 and 35 inclusive will be generated and output. Write pseudocode for this algorithm.
- Write pseudocode for this algorithm.[8]
Mark scheme
Marking points from the official mark scheme (May/June 2025). The mark or mark type is shown in brackets.
- [8] Example solution DECLARE FirstNumber : INTEGER DECLARE SecondNumber : INTEGER DECLARE ThirdNumber : INTEGER FirstNumber ← INT(RAND(21)) - 10 OUTPUT FirstNumber REPEAT SecondNumber ← INT(RAND(21)) - 10 UNTIL FirstNumber <> SecondNumber OUTPUT SecondNumber IF FirstNumber < 0 AND SecondNumber < 0 THEN ThirdNumber ← INT(RAND(6)) + 30 OUTPUT ThirdNumber ENDIF Mark points: 1. Declare all variables used 2. Use RAND() function with any integer parameter 3. Use INT() function with any numeric parameter 4. Conditional loop until two different random numbers are generated 5. Use INT () function using random number generated between –10 and 10 inclusive in a loop 6. Output two different random integers / numbers 7. Check if both random integers / numbers are negative 8. then output a (third) random integer / number between 30 and 35 inclusive
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 →