Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answers only in C language please. 2 functions question. Write a Junction with p

ID: 3534452 • Letter: A

Question

answers only in C language please. 2 functions question.

Write a Junction with prototype void init_rand(float x[], int size, float min, float max); The function should assign a random real number between min and max to each variable of the array x. The parameter size is the number of variables in array x. Assume that the srand function has already been called to seed the random number generator void init_rand (float x [ ] , int size, float min, float max) Write a function with prototype void init_rand ( int x[], int size, int min, int max); The function should assign a random integer between min and max to each variable of the array x The parameter size is the number of variables in array x. Assume that the srand function has already been called to seed the random number generator. void init_rand (int x[], int size, int min, int max) {

Explanation / Answer

Hey, please rate with 5 stars since I am giving you the copncept as well


Firstly, you need to traverse each elements by a for loop.

Then for each element, you need a number >=min but a random value.


Therefore You can use the Math.random() function which returns a value between 0 and 1.


Therefore min+ Math.random()max will give you numbers from [min, min+max]


Please rate with 5 :)


void init_rahd(float x[],int size, float min, float max)

{for(i=0;i<size;i++)

{

x[i]=min+Math.random() * max;

}

}