Question: Programmed in C void initialize_array(int *, int ): This function takes an integer pointer and the input size and stores random numbers using the integer

Programmed in C

void initialize_array(int *, int ): This function takes an integer pointer and the input size and stores random numbers using the integer pointer. The random numbers range from the value 1 to 5 only.

void print_array(int *, int): This function takes an integer pointer and the input size and prints out random numbers using the integer pointer.

int check_size(int): This function takes an integer number and checks if the number is between 1-50 or not. If it is, it returns 1, otherwise returns 0.

float mean (int *, int): This function takes an integer pointer (to an integer array) and the input size and returns the average of all the numbers in the array.

main(): First read the input size from the user, performing an error check using the check_size function. Call functions initialize_array and print_array to store and print the random numbers. Display the results as shown in the sample output below.

Function calls:

int array[MAX];

int *p =array;

init_array( p, size);

print_array(p, size);

float avg= mean(p, size);

Function Body:

void init_array( int *pointer, int size){

// Everything here

}

void print_array(int *pointer, int size){

}

float mean(int *pointer, int size){

//logic here

return average;

}

Note:

1. In the main declare an integer pointer and declare an integer array of size 50, assign the address of this array to the declared integer pointer and pass this pointer to all the functions.

2. Use only pointer notation and pointer arithmetic to implement the assignment.

3. Use the relevant library function, the ones you have used already.

Sample output

Enter the size of the input: -12

Invalid input enter the size of the array again: 123

Invalid input enter the size of the array again: 0

Invalid input enter the size of the array again: 6

Input array

1 2 1 5 2 5

Average is : 2.66

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!