#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#define MAX 50

void input(int *n, int IDs[MAX], float grades[MAX]);
void printALL(int n, int IDs[MAX], float grades[MAX]);
void findHighestGrade(int n, int IDs[MAX], float grades[MAX]);
void findLowestGrade(int n, int IDs[MAX], float grades[MAX]);
void printHighestGrade(int n, int IDs[MAX], float grades[MAX]);
void printLowestGrade(int n, int IDs[MAX], float grades[MAX]);
void printMenu();

int main()
{
int n = 0;
int IDs[MAX];
float grades[MAX];
int option = 0;
do
{
printMenu();
scanf("%d", &option);
switch(option)
{
case 1:
input(&n, IDs, grades);
break;
case 2:
printALL(n, IDs, grades);
break;
case 3:
printHighestGrade(n, IDs, grades);
findHighestGrade(n, IDs, grades);
break;
case 4:
printLowestGrade(n, IDs, grades);
findLowestGrade(n, IDs, grades);
break;
case 5:
exit;
break;
default :
printf("Your option is invalid");
break;
}
}while(option > 5);
return 0;
}

void printMenu()
{
printf("\t1. Input grade: \n");
printf("\t2. Print all students information\n");
printf("\t3. Print highest grades\n");
printf("\t4. Print lowest grades\n");
printf("\t5. Exit\n");
printf("Please enter your option:");
}

void input(int *n, int IDs[MAX], float grades[MAX])
{
printf("\nInput student ID: ");
scanf("%d", &IDs[*n]);
printf("Input student grade: ");
scanf("%f", &grades[*n]);
(*n)++;
}

void printALL(int n, int IDs[MAX], float grades[MAX])
{
system("cls");
for(int i = 0; i < n; i++)
{
printf("\n- The students' informations #%d:\n", i + 1);
printf("\t + ID: %d\n", IDs[i]);
printf("\t + Grade: %.2f\n", grades[i]);
}
printf("\nPress any key to back the menu: ");
getchar(); getchar();
}

void findHighestGrade(int n, int IDs[MAX], float grades[MAX])
{
float max;
for(int i = n; i < n; i++)
{
if(grades[i] > max)
{
grades[i] = max;
}
}
}

void findLowestGrade(int n, int IDs[MAX], float grades[MAX])
{
float min;
for(int i = n; i < n; i++)
{
if(grades[i] < min)
{
grades[i] = min;
}
}
}

void printHighestGrade(int n, int IDs[MAX], float grades[MAX])
{
printf("The highest grade: %f", &grades);
}

void printLowestGrade(int n, int IDs[MAX], float grades[MAX])
{
printf("The lowest grade: %f", &grades);
}