Problem Description: Write a program to randomly generate integer data values in
ID: 440007 • Letter: P
Question
Problem Description: Write a program to randomly generate integer data values into an array which can hold 25 values. The program should ask the user to enter the minimum and maximum values in a numeric range that is not less than 1 and not greater than 500. Validate that the user enters the numbers correctly (minimum first >= 1 and then maximum <= 500) and correct the errors if not. The program should then generate 25 random numbers in that range and store them in the array. After filling the array, the program should calculate the total of all the values that are even numbers and the total of all the values that are odd numbers. Then the program should calculate the square root of each of those totals (hint: cmath library function). Display all 25 values in the array. Display the total of the even numbers and the square root of that total. Display the total of the odd numbers and the square root of that total. Required Functions: ? A function which reads and validates the minimum and maximum values that the user enters. This will require reference parameters in order to return both values to the function call. ? A function which can generate random numbers in a sequential range and return the number generated. This function should be able to work with any sequential range of numbers not specific to this program. ? A function which will calculate the total of the even numbers and the total of the odd numbers in the array. This function will have to use two parameters passed by reference to store the totals. The function will also need an array parameter which cannot be modified in the function. The function will also need a parameter to store the size of the array which cannot be modified in the function. ? A function to display the array.Explanation / Answer
#define ELEMENTS 25 void insertion_sort(int x[],int length); void insertion_sort_reverse(int x[],int length); int main() { clock_t tStart = clock(); int B[ELEMENTS]={4,2,5,6,1,3,17,14,67,45,32,66,88, 78,69,92,93,21,25,23,71,61,59,60,30}; int x; coutRelated 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.