Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a short program that reads in a positive integer from the user that says h

ID: 3821700 • Letter: W

Question

Write a short program that reads in a positive integer from the user that says how many numbers to enter, then enters each number (assume valid inputs), then print out some statistics Printout must include mean, median, and mode and mean median and mode must be in separate functions that rectum the result. Function prototypes are below. You may assume a sort function exists as well as mean. Just write median and mode and the rest of main. A helper function fill Array is provided, it takes in an array as an argument and fills with the integer data needed (not in order and no repeating values). int mean (int array[], int size)1//Already exists int median (int array[] int size): int mode (int array[] int size): int sort (int array[] int size)://Already exists void fill Array (int array[] int size)//Already exists int main(){int numElements1 printf ("Enter number of elements:): scanf (d* shunt elements)://create the array//call functions and print results to user

Explanation / Answer

int mean(int array[],int size);

int median(int array[],int size);

int mode(int array[],int size);

int sort(int array[],int size);

void fillArray(int array[],int size);
double findMean(int array[],int numElements)

double findMedian(int array[],int numElements)

double findMode(int array[],int numElements)

void printresults(double mean, double median, double mode);

int main()

{

int numElements;

double mean,median,mode;

printf(“enter number of elements:”);

scanf(“%d”,&numElements);

}

void fillArray(int array[],int numElements)

int temp,i;

printf( “enter the %i numbers:” numElements);

for(i=0;i<=numElements-1;i++) {

scanf(“%i”,&array[i]);

}

}

double findMean(int array[],int numElements)

int i;

double sum=0.0;

for(i=0;i< numElements;i++)

{

sum+=array[i];

}

return(sum/numElements);

}

double findMedian(int array[],int numElemnts)

{

int temp,i,j;

for(i=0;i<numElements;i++)

for(j=i+1;j<total;j++) {

if(array[i]>array[j]) {

temp=array[j];

array[j]=array[i];

array[i]=temp;

}}

if(numElemnts%2==0){

int x,y;

x=array[numElements/2];

y=array[(numElemnts/2)-1];

return((x+y)/2);

} else

{

return array[numElements/2];

}}

int findMode(int array[],int numElements) {

     int i, j, max, mode;

    int tally[numElemnts];

    for (i = 0; i < numElements; i++) {

        tally[array[i]]++;

    }

     max = 0;

    mode = 0;

    for (j = 0; j < numElements; j++) {

        if (tally[j] > max) {

            max = tally[j];

            mode = j;

        }

    }

    return mode;

}

void printresults(double mean, double median, double mode)

{

    printf("Mean: %f Median: %f Mode: %f", mean, median, mode);

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote