Question
IN C LANG PLEASE! This assignment requires you to use structures and array of structures. Students name, age and year in College are stored in
IN C LANG PLEASE!
This assignment requires you to use structures and array of structures. Students name, age and year in College are stored in the each of the record . There are 8 students in the list.
THE DATA:
Erik 21 A
Jeff 22 A
Beth 23 D
Brad 24 D
Cindy 28 C
Bill 25 B
Jack 26 C
Jill 29 D
The structure definition is already given to you.
struct _Student { char name [32] ; unsigned char age ; char yearInCollege ; } ;
The list is also given in an array of structures.
Go through the C program and Search for the tasks you are supposed to do, namely:
THE PROGRAM:
// COMPLETE ALL FOUR TASKS
#include
struct _Student {
char name [32] ;
unsigned char age ;
char yearInCollege ;
} ;
struct _Student StudentList [ 8 ] =
{
// TASK 1 FILE THE CODE TO INITIALIZE THIS STRUCURE WITH DATA GIVEN ABOVE
CANVAS
};
//Task 2: Write A function , note this function uses pointer
void printStudentList(struct _Student *ptr, int num )
{
int i ;
printf ( " " );
// FILL IN THE CODE TO PRINT ALL FIELDS IN EACH RECORD
}
// TASK 3 : complet the function to sort the records
void sortStudentListUsingAge(struct _Student ptr[ ], int num )
{
int i , j;
}
//Task 4 : Write a Function to sort the list using Year in College in ascending order
void sortStudentListUsingYearInCollege(struct _Student ptr[ ], int num )
{
}
//Task 5 : Write a Function to sort the list using Name in ascending order
void sortStudentListUsingName(struct _Student ptr[ ], int num )
{
}
int main ( )
{
int numCells = sizeof ( StudentList)/ sizeof ( StudentList[0]);
printStudentList(StudentList , numCells) ;
sortStudentListUsingAge(StudentList, numCells) ;
printStudentList(StudentList , numCells) ;
sortStudentListUsingYearInCollege(StudentList, numCells) ;
printStudentList (StudentList , numCells) ;
sortStudentListUsingName(StudentList, numCells) ;
printStudentList(StudentList , numCells) ;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started