Question: Instructions You will need to write the following functions: printArray - takes an array and an integer representing the size of the array as input
Instructions
You will need to write the following functions:
printArray - takes an array and an integer representing the size of the array as input and prints the array to the console
findInArray - takes an array and two integer as input, one for array size and the other as a search value, and searches the array for the integer. It returns the index of the integer if found, and -1 if it is not found. Do not worry about duplicates, just return the first one you find.
getFrequency - takes an array and an integer representing the size of the array as input. This array counts the how often a number occurs in the input array - the frequency. Created an array of 21 integers called frequency. Starting with the first index of the frequency array, count the number of times that index exists in the input array. Store that number in the frequency array and move to the next index and repeat. When you are done, PRINT the frequency array.FOR EXAMPLE - {2, 1, 1, 2, 1, 0, 2, ,0 ,1, 0, 2, 2} => {3, 5, 4}
The input array has 3 zeros, 4 ones and 5 twos
You will write a program that does the following
declare an array of 100 integers
declare an integer to represent the size of the array
initials the array with 100 random integers between 0 and 20 (inclusively)
call the print array function with the array as input
prompt the user for an integer use your array and the integer to call the findInArray function. When the function returns, print the results. Repeat this 10 times.
call the getFrequncy function with your array as input. In the frequency function print the resulting array with the print array function.
In the frequency function, use a loop to calculate and print the following
the sum of the array
the average of the array
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
