![]() |
VOOZH | about |
Making projects is one of the most interesting and fun ways to learn a programming language such as C. In this article, we will learn how to write code for the Student Management System in C.
This project is a simple console-based Student Management System built using the C programming language. It allows for basic operations such as:
The system uses a singly linked list to dynamically manage student records in memory. Each student is represented by a struct that stores details such as their ID, name, age, gender, and class number.
The whole project contains features as follows:
- Add Student: Adds a new student to the beginning of the list with provided details.
- Delete Student: Deletes a student based on their ID. If the ID doesn't exist, it notifies the user.
- Search Student: Finds and displays a student record by ID if it exists.
- Display by Class: Lists all students who belong to a given class, showing their ID, name, age, and gender.
Expected Output Behaviour:
The addStudent function takes arguments such as id, name, age, gender, and classNumber. It dynamically allocates memory for a new student using malloc, assigns these values to the respective fields of the student structure, and then inserts the student at the beginning of the linked list.
The deleteStudent function takes a student ID as input and searches through the linked list to find a matching student. If found, it removes that student from the list by updating the pointers, frees the allocated memory for that student using free(), and prints a confirmation message. If the student is not found, it displays an appropriate message.
The searchStudent function takes a student ID as input and traverses the linked list to find a student with the matching ID. If found, it prints the student's details such as ID, name, age, gender, and class number. If no student with the given ID is found, it displays a message indicating that the student does not exist.
4. Display by Class
The displayByClass function takes a class number as input and traverses the entire linked list of students. It prints the details (ID, name, age, gender, and class number) of all students who belong to the given class. If no students are found in that class, it displays an appropriate message.
Below is the full program for the Student Management System in C language: