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

Rework the following code creating statistics for each student. Print the studen

ID: 3647372 • Letter: R

Question

Rework the following code creating statistics for each student. Print the students' high, low, and average scores to the right of Quiz 5. Provide appropriate column headings.

#include<stdio.h>
int findMin(int *array, int n, int k)
{
int result = 999999;
int i;
for (i = n; i <= n+5*(k-1); i += 5)
if (array[i] < result)
{
result = array[i];
}

return result;
int findMax(int *array, int n, int k)
{
int result = 0;
int i;
for (i = n; i <= n+5*(k-1); i += 5)
if (array[i] > result)
{
result = array[i];
}

return result;
}

float average(int *array, int n, int k)
{
int result = 0;
int i;
for (i = n; i <= n+5*(k-1); i += 5)
result += array[i];

return (result + findMax(array, n, k)+findMin(array, n, k))/(k+2);
}

int main()
{
FILE *input;
FILE *out;
int student;
int score[10000];
int n,k;


input = fopen("data.txt", "r");
out = fopen("out.txt","w");

if (input == NULL)
fprintf(stderr, "Can't open input file. ");
else
{
n = 0; k = 0;
fprintf(out, "Student Quiz 1 Quiz 2 Quiz 3 Quiz 4 Quiz 5 Average ");

while (fscanf(input, "%d %d %d %d %d %d",
&student,
&score[0+n],
&score[1+n],
&score[2+n],
&score[3+n],
&score[4+n])
!= EOF)
{
fprintf(out," %d %d %d %d %d %d ",
student,
score[0+n],
score[1+n],
score[2+n],
score[3+n],
score[4+n]);
n += 5;
k++;
}

fprintf(out, " High %d %d %d %d %d ",
findMax(score, 0, k),
findMax(score, 1, k),
findMax(score, 2, k),
findMax(score, 3, k),
findMax(score, 4, k) );
fprintf(out, " Low %d %d %d %d %d ",
findMin(score, 0, k),
findMin(score, 1, k),
findMin(score, 2, k),
findMin(score, 3, k),
findMin(score, 4, k) );
fprintf(out, " Aver %.1f %.1f %.1f %.1f %.1f ",
average(score, 0, k),
average(score, 1, k),
average(score, 2, k),
average(score, 3, k),
average(score, 4, k) );
}

return 0;
}

I believe I've figured out how to get the average of the rows to the side but am still having difficulty with high and low, please help

Explanation / Answer

after correcting some code:- #include int findMin(int *array, int n, int k) { int result = 999999; int i; for (i = n; i
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