Write a C/C++ program to perform the task of maintaining student information for 123 College. You are to use a linked-list for storing the student records. Each student record contains the student’s name and age, and it should be a node in the linked-list. Your program should have an insert(), delete(), and print() functions. The prototypes are given below:

void insert( struct student **headOfList, char *name, int age );
int delete( struct student **headOfList, char *name );
void print( struct student *headOfList );



The insert() function inserts the node in increasing alphabetical ordering.

Perform the following tasks in the main() function of your program:

1) Add the following 3 students to the linked-list (which is initially empty), one at a time:
a) John, 18
b) Sally, 19
c) Matt, 18
2) After adding the 3 students, print out the whole list using the print function.
3) Add the following student to the list, and print out the resulting list.
d) Jason, 18
4) Compute and print out the average age of the 4 students by traversing the linked-list.
5) Delete the student Matt from the list and print out the resulting list.

The print() function should output each of the students’ name and age in a readable fashion. Make sure the output is properly formatted and each printing can be distinguished from the other.



MARKING CRITERIA

Program 1
- Insert() function
- Delete() function
- Print() function
- Main() function
- Output Format
- Formatting, variable names, comments, alignment
- Use of malloc()






TASK 2

Write a second C/C++ program to implement the stack functionality using a linked-list. The stack functions you need to implement are:

void push( struct student **stack, char *name, int age );
struct student * pop( struct student **stack );
int isEmpty( struct student *stack );

These three functions have the normal stack functionalities. Perform the following tasks in the main() function of your program:

1) Create an empty stack.
2) Push 3 students onto the stack ( “Ahmad”, 20; “Beng”, 21; “Cathy, 18 )
3) Pop a student from the stack and display that student’s information
4) Push another student onto the stack ( “David”, 25 );
5) Pop the stack one student at a time until the stack is empty. Each time you popped a student from
the stack, print out that student’s information.





MARKING CRITERIA


Program 2
- Push() function
- Pop() function
- IsEmpty() function
- Main() function
- Output Format
- Formatting, variable names, comments, alignment
- Use of malloc()