Question 4 2017 · October-November · Paper 22 · 0 marks
Reveal official mark-scheme answer
The answer for this question is in the official mark scheme: open the mark scheme.
Show text version of question
Question 4
Programming languages provide built-in functions to generate random numbers. To be truly random, the frequency of each number generated should be the same. You are required to write program code to test the random number generator of your chosen language. The test should: • generate a given number of random numbers between 1 and 10 inclusive • keep a count of the number of times each number is generated • calculate the expected frequency of each number 1 to 10 • output the actual frequency of each number 1 to 10 • output the difference between the actual frequency and the expected frequency. The program code should be written as a procedure. In pseudocode, the procedure heading will be: PROCEDURE TestRandom(Repetitions AS INTEGER) The parameter, Repetitions, contains a value representing the total number of random numbers that should be generated. The following example shows the expected output for the procedure call, TestRandom(200). The expected frequency is 20. Number Frequency Difference
Question 1
Question 17
−3
Question 2
Question 21
Question 1
Question 3
Question 12
−8
Question 4
Question 28
Question 8
Why this question appears here
71% assigned-topic match · Programming › Structured programming
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_w17_qp_22.pdf
