Question
Use array notation only to create the pointer (in order to store a list of numbers) So... #define MAX 50 int array[MAX]; int *pointer =
Use array notation only to create the pointer (in order to store a list of numbers)
So...
#define MAX 50
int array[MAX];
int *pointer = array;
void get_size(int *): This function takes in an integer pointer from main, but does not have a return type. The function will read in the size of the pointer, but you will not type "return size;" or something similar. Since the variable being taken into the parameters of the function is a pointer, it is being passed by reference so anything that happens to the variable in "get_size" also happens to it in main which is different from how we normally pass a variable (pass by value).
int check_size(int): This function takes an integer number and checks if the number is between 1-50 or not. If it is, returns 1, otherwise returns 0.
void initialize_pointerArray(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 10 only.
void print_pointerArray(int *, int): This function takes an integer pointer and the input size and prints out random numbers using the integer pointer.
int find_max (int *, int): This function takes in an integer pointer and the input size and returns the largest value stored in the pointer
int find_min (int *, int): This function takes in an integer pointer and the input size and returns the smallest value stored in the pointer.
void buble_sort(int *, int): This function takes in an integer pointer and the input size. The function will then implement a bubble_sort algorithm (without using built-in sorting functions) to sort the pointer in ascending order.
float find_median(int *, int): This function takes in an integer pointer and the input size, and returns the median of the list of numbers within the pointer. Note that if there is an odd number of digits in the pointer, then the median will be the middle value. If even, the median will be the average of the two "middle numbers"
main(): First read the input size from the user by calling get_size, performing an error check using check_size function. Call functions initialize_array and print_array to store and print the random numbers. Then, call find_max and find_min to return the largest and smallest values in the pointer. After thatm call bubble_sort to sort the pointer in ascending order then print the newly sorted pointer. After that, call find_median to find the "middle" value of the sorted pointer.
Output should look like
Enter the size of pointer: 109
Try again: -1
Try again: 7
Pointer is 9 1 5 1 9 4 5
The min of all numbers = 1
The max of all numbers = 9
The sorted pointer is: 1 1 4 5 5 9 9
The median of the pointer = 5.00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started