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

Write a C program that reads a file of integers. Finds the smallest, largest, su

ID: 3769395 • Letter: W

Question

Write a C program that reads a file of integers. Finds the smallest, largest, sum, average (mean) and median. It also counts how many times each number is seen.

You are given a start program with code to sort an array of integers and print an array of integers.

You must write the other functions your self.

Functions:

int main ( int argc, char * argv[] )

declare variables

fillArray(

getStats(

getModes(

sort(

writeStats

int fillArray( int array[1000] )

receives an array of integers

opens file in.txt

reads the integers from the file storing each in the array

closes the file

returns a count of how many ints in the array. If count is 1 then array[0] is only element with a valid integer

void getStats(int array[], int count, int &min, int &max, int &sum)

receives array and count

returns:

the smallest in min

largest in max

total in sum

void getModes( int array[], int count, int counts[100])

receives array count integers, initialize all elements to 0

loop thru the array and add one to the proper count counts[ array[i] ] ++;

returns the counts array with count of number 0 in counts[0], 1 in counts[1] etc.

void writeStats(int counts[100], int count, int min, int max, int sum, int median)

opens file out.txt

Writes to file with labels:

count of how many integers read

min, max, sum, average and median

Label then the numbers 0-100 followed by count of how many times they occurred 5 per line

0 - 3, 1 – 2, 2 – 5, 3 – 0, 4 – 6, 5 – 22 6 – 0, and so on

close file

Rules: There will be <= 1000 numbers in the file we use to test your code Each number will be >= 0 and <=99 We will give you a small input file for testing We will use a much larger file

Explanation / Answer

#include #include int main(int argc, char*argv[]) { double average, num = 0, min = 0, max = 0, sum = 0, N, std_dev, sum_sqs = 0.0; if (argc
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