Question: Write a program to fill a vector with 5000 random numbers. Then display: The smallest number The largest number The number of odd values The
Write a program to fill a vector with 5000 random numbers. Then display:
The smallest number
The largest number
The number of odd values
The number of even values
The total of the values
The average of the values
Ask the user for an integer and display the subscript of the cell where it was found or NOT FOUND! if it isnt found.
You will be using a binary search to locate the index of the integer requested by the user. Since you will be using a binary search, the vector will have to be in order. There are two functions that you will need to include in your code to sort your vector - shellSort() and swapper(). the code is:
void shellSort(vector
int d = numLength; while (flag || (d>1)) // bool flag { flag = false; //reset flag to 0 to check for // future swaps d = (d + 1) / 2; for (i = 0; i
flag = true; //tells swap has occurred } } } } void swapper(int &a, int &b) { int temp; temp = a; a = b; b = temp; }

Each of the preceding values should be determined by a function and returned to main where they should be displayed CWindowslsystem32\cmd.exe The smallest number is The largest number is 32766 12 he nunber of evens is 2545 The number of odds is 2454 The total of the values is 82484206 The average of the values is 16496.84 Enter an integer: 781 781 was found at position 120 Press any key to continue - . - _
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
