Question: Here is my code from the prior assignment. I need to make this into seperate source files. #include #include #define STUDENTS 6 #define LABS 7
Here is my code from the prior assignment. I need to make this into seperate source files.
#include
#include
#define STUDENTS 6
#define LABS 7
void printAvgs (int size, float theArray[], char *ptr); //prototype
void printSorted (int count, int line[]); //prototype
int getGrades (int grades[STUDENTS][LABS]); //prototype
int printGrades (int grades[STUDENTS][LABS]); //prototype
int studentAvgs (int grades[STUDENTS][LABS]); //prototype
int labAvgs (int grades[STUDENTS][LABS]); //prototype
int sortGrades (int grades[STUDENTS][LABS]); //prototype
void printAvgs (int size, float theArray[], char *ptr) //Function to print student and lab averages
{
int i, y=1;
for (i = 0; i
printf ("%s %i average: %.2f ", ptr, y, theArray[i]);
++y;
}
printf (" ");
}
void printSorted (int count, int line[]) //Function to print the sorted grades
{
int a, array[count];
for (a = 0; a
printf ("%d ", line[a]);
}
printf (" ");
}
int getGrades (int grades[STUDENTS][LABS]) //Function to get grades
{
int i, j, k, array[STUDENTS * LABS];
for (i = 0; i
for (j = 0; j
fscanf (stdin, " %d", &grades[i][j]);
}
}
return 0;
}
int printGrades (int grades[STUDENTS][LABS]) //Function to print grades
{
int i, j, count=1;
printf (" ");
for (i = 0; i
fprintf (stdout, "Student %d: ", count);
count++;
for (j = 0; j
fprintf (stdout, " %4d ", grades[i][j]);
}
printf (" ");
}
printf (" ");
return 0;
}
int studentAvgs (int grades[STUDENTS][LABS]) //Function to calculate student averages
{
int i, j, y=1;
float avg=0, sum=0;
float stuAvg[STUDENTS];
char chicken[7] = {"Student"};
for ( i = 0; i
for ( j = 0; j
sum += grades[i][j];
avg = sum / LABS;
stuAvg[i] = avg;
sum=0;
}
printAvgs(STUDENTS, stuAvg, chicken);
return 0;
}
int labAvgs (int grades[STUDENTS][LABS]) //Function to calculate lab averages
{
int i, j, y=1;
float avg=0, sum=0;
float labAvg[LABS];
char chicken[3] = {"Lab"};
for ( j = 0; j
for ( i = 0; i
sum += grades[i][j];
avg = sum / STUDENTS;
labAvg[j] = avg;
sum=0;
}
printAvgs(LABS, labAvg, chicken);
return 0;
}
int sortGrades (int grades[STUDENTS][LABS]) //Function to sort the grades
{
int a=0, b=0, i, j, k=0, count=0, array[STUDENTS*LABS], min=0;
double temp;
count = STUDENTS*LABS;
for (i = 0; i
for (j = 0; j
array[k] = grades[i][j];
k++;
}
}
for (a = 0; a
min = a;
for (b = a + 1; b
if (array[b]
min = b;
temp = array[a];
array[a] = array[min];
array[min] = temp;
}
printf (" ");
printSorted( count, array);
return (0);
}
int main (void)
{
int grades[STUDENTS][LABS];
getGrades(grades); //call funtiont to get grades
printGrades(grades); //call function to print grades
studentAvgs(grades); //call function to calculate student averages
labAvgs(grades); //call function to calculate lab averages
sortGrades(grades); //call function to sort grades
return 0;
}


![7 void printAvgs (int size, float theArray[], char *ptr); //prototype void printSorted](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f46677dcb24_04766f466774d127.jpg)
![(int count, int line[]); //prototype int getGrades (int grades[STUDENTS][LABS]); //prototype int printGrades](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f466787dc21_04866f46678101e3.jpg)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
