Write a program that asks the user to inter an array of integers and the number
ID: 3544155 • Letter: W
Question
Write a program that asks the user to inter an array of integers and the number of elements in the array and then print out the mode and median of the array. Write a Mode function to determine the mode of the array. And also write a Median function to determine the median of the array.
Mode function: This function should accept as arguments the following:
A) An array of integers
B) An integer that indicates the number of elements in the array.
The function should determine the mode of the array. That is, it should determine which value in the array occurs most often, the mode is the value the function should return. If the array has no mode (none of the values occur more than once), the function should return -1. (Assume the array will always contain nonnegative values). Use pointer notation instead of array notation.
Median function: This function should accept as arguments the following:
A) An array of integers
B) An integer that indicates the number of elements in the array.
The function should determine the median of the array. This value should be returned as a double. In statistics, when a set of values is sorted in ascending or descending order, its median is the middle value. If the set contains an even number of values, the median is the mean or average of the two middle values. Use pointer notation instead of array notation.
Explanation / Answer
#include using namespace std; //variables int basArray[10]; int askNum; int V; bool youWin = false; int main() { while(1) { for (int f = 0; f < 10; f++) { cout > basArray[askNum]; } cout > V; for (int n = 0; n < 10; n++) if (basArray[n] == V) { youWin = true; break; // found match, don't check any more } if (youWin) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.