Question: Write a program to count each whole number between 1 and 1 0 0 and then report the mode. The program should prompt the user

Write a program to count each whole number between 1 and 100 and then report the mode. The program should prompt the user for numbers until the user enters a value that is NOT between 1 and 100. When determining the mode, choose the largest number if multiple numbers are tied for the most frequent.
Create two separate functions, one for counting the input values and another for searching for the largest count.
countInputValueswill accept an integer array and its length as parameters. Each element of the array will represent the count for a number. For example,count[0]represents the number of 1's the user has entered. The function will prompt the user for numbers between 1 and 100. Then it will update the array at the appropriate index.
modeIndexwill also accept an integer array and its length as parameters. This function will return the index of the mode (i.e., the location in the array containing the largest value). If multiple numbers are tied for the most frequent, return the largest index. Remember, any array parameter that isn't modified within the function should beconst.
Output the result in this format:
Sample Output (user input is in yellow)
Enter a number between 1 and 100(or 0 to exit): 3 Enter a number between 1 and 100(or 0 to exit): 100 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 100 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 42 Enter a number between 1 and 100(or 0 to exit): 0 The most frequent value was 42, appearing 7 times.

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 Programming Questions!