Code:
#include <stdio.h>
#define students 3
#define exams 4
/* function prototypes */
void minimum( const int[][ exams ], int, int );
void maximum( const int[][ exams ], int, int );
void average( const int[][ exams ], int, int );
void printArray( const int[][ exams ], int, int );
int main()
{
const int studentGrades[ students ][ exams ] =
{ { 77, 68, 86, 73 },
{ 96, 87, 89, 78 },
{ 70, 90, 86, 81 } };
void (*f[4])(int [][ exams ], int, int) =
{printArray,minimum,maximum,average};
int choice;
printf( "Enter a choice:\n");
printf( "0 Print the array of grades\n");
printf( "1 Find the minimum grade\n");
printf( "2 Find the maximum grade\n");
printf( "3 Print the average on all test for each student\n");
printf( "4 End Program\n");
scanf( "%d", choice);
while( choice >= 0 && choice < 4 ){
(*f[choice])(studentGrades,students, exams);
printf( "Enter a number between 0 and 3, 4 to end: ");
scanf( "%d", &choice);
}
printf( "Program execution completed.");
return 0;
}
void printArray( const int studentGrades[students][ exams ], int
students, int exams )
{
int i;
int j;
printf( " [0] [1] [2] [3]" );
for ( i = 0; i < students; i++ ) {
printf( "\nstudentGrades[%d] ", i );
for ( j = 0; j < exams; j++ ) {
printf( "%-5d", studentGrades[ i ][ j ] );
}
}
}
/* Find the minimum grade */
void minimum( const int studentGrades[students][ exams ], int
students, int exams )
{
int i;
int j;
int lowGrade = 100;
for ( i = 0; i < students; i++ ) {
for ( j = 0; j < exams; j++ ) {
if ( studentGrades[ i ][ j ] < lowGrade ) {
lowGrade = studentGrades[ i ][ j ];
printf( "Lowest Grade is %d",lowGrade);
}
}
}
}
/* Find the maximum grade */
void maximum( const int studentGrades[students][ exams ], int
students, int exams )
{
int i;
int j;
int highGrade = 0;
for ( i = 0; i < students; i++ ) {
for ( j = 0; j < exams; j++ ) {
if ( studentGrades[ i ][ j ] > highGrade ) {
highGrade = studentGrades[ i ][ j ];
printf( "Highest Grade is %d", highGrade);
}
}
}
}
/* Determine the average grade for a particular student */
void average( const int studentGrades[students][exams], int students,
int exams)
{
int i;
while(i < students){
int sum = 0;
double avg = 0.00;
for ( j = 0; j < exams; j++ )
sum += studentsGrades[ i ][ j ];
avg = static_cast<double>(sum)/exams;
printf( "The average grade for student %d is %.2f", i, avg);
i++;
}
}
what was i thinking please end my misery