Write a C program that generates 100 random numbers between 1 and 1000 and displ
ID: 3910809 • Letter: W
Question
Write a C program that generates 100 random numbers between 1 and 1000 and displays the minimum number and number of its occurrence in the array. Your program should a. fillArray (int nums[], int n): To generate 100 random numbers between b. recursiveMinimum (int nums [], int size): a recursive function that returns implement the following functions: 1 and 1000 and stores them in array nums the smallest element of the array. The function should stop processing and return when it receives an array of one element. c. int findFreq (int nums[], int size, int key): To find and return the number of occurrence of the minimum number found by recursiveMinimum in the input array d. void displayArray (int nums[, int size): To display the array elements (10 numbers in 10 rows).Explanation / Answer
#include<stdio.h>
//recursive method to find the smallest element in array num
int recursiveMinimum(int num[],int size)
{
int min;//variable to store index to the smallest number
if(size==0)
return num[0];
min = recursiveMinimum(num,size-1);
if(num[size-1]<min)//updating min
return num[size-1];
return min;
}
int main()
{
int a[] = {8,2,4,7,5};
printf("%d ",recursiveMinimum(a,5));
return 0;
}
output:
2
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.