Question: Question B. (15 marks] Write a program to do the following tasks. Generate x random integers, the values of which are in the range [2,
![Question B. (15 marks] Write a program to do the following](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66eff910de8db_89666eff9107cbef.jpg)
Question B. (15 marks] Write a program to do the following tasks. Generate x random integers, the values of which are in the range [2, y]. The values of x and y are decided by the user, and both no larger than 100. Calculate and print the number of times each integer in [2, y] occurred in these x random integers. For example, suppose x=9, y=6 and the generated random integers are 4, 4, 3, 6, 4, 4, 3, 2, 6 then the result is w! where 2: 1" means 2 occurs once, 3:2" means 3 occurs twice and so on. Print the values in [2, y] in decreasing order of the number of times they occurred. If two values in [2, y] occurred the same number of times, they should be decreasingly ordered by their own values. With the above example, the result is 4, 6, 3, 2,5 where 6 is ordered before 3 since 6 is larger than 3, although they both occuired twice
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
