Question: You will implement a simple function, generate_random (int arr[], int cnt). The function generates non-duplicated random numbers and stores them to the array address (arr).
![You will implement a simple function, generate_random (int arr[], int cnt).](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3104191925_44166f3104104951.jpg)

You will implement a simple function, generate_random (int arr[], int cnt). The function generates non-duplicated random numbers and stores them to the array address (arr). The second argument (cnt) indicates how many numbers need to be generated. You can assume that the generated random numbers are between 1 ~ 9 and cnt is the size of array (less than 10). For function call, generate_random (arr, 6) arr[] = {5, 2, 1, 4, 6, 3} valid valid arr[] = {1, 3, 4, 2, 5, 7} arr[] = {9, 5, 2, 3, 1,5) invalid ('5' is duplicated) arr[] = {9, 5, 2, 3, 1} invalid (generated numbers is 7) invalid (generated numbers is 5) arr[] = {9, 5, 2, 3, 1, 4, 6} The main function will call generate_random () to generate non-duplicated numbers. arr: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 (up to 9 numbers) If you call generate_random (arr, 9), the array (arr ) will include all numbers from 1 to 9. You will also need to change the second parameter (cnt) to test your code
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
