Given the following definition of a StudentRecord and #define's:
typedef struct { char name[MAX_NAME_LEN]; int stID; double cse142Grade; } StudentRecord; #define LESS -1 #define EQUAL 0 #define GREATER 1
Write a function which:
void swapStudentRecords(StudentRecord *first, StudentRecord *second) { StudentRecord temp = *first; *first = *second; *second = temp; } int compareByName(StudentRecord *first, StudentRecord *second) { int result = strcmp(first->name, second->name); return result; } int compareByID(StudentRecord *first, StudentRecord *second) { if(first->stID > second->stID) return GREATER; else if(first->stID < second->stID) return LESS; else return EQUAL; } int compareByGrade(StudentRecord *first, StudentRecord *second) { if(first->cse142Grade > second->cse142Grade) return GREATER; else if(first->stID < second->stID) return LESS; else return EQUAL; }