Introduction
Introduction
Objectives
The primary objectives of this project include:
1. Storing Student Data: Managing details such as name, ID, subject,
and grade.
2. Providing Easy Access: Allowing users to quickly search for
specific student records.
3. Editable Records: Supporting the addition and deletion of records.
4. Learning Opportunity: Demonstrating the use of structs,
functions, loops, and file handling in C programming.
Project Features
The project implements the following key functionalities:
1. Add Student Details
o Input data like name, ID, subject, and grade for a student.
o Store the data in a structure to manage multiple records
efficiently.
2. View All Students
o Display all stored student records in a tabular format for easy
viewing.
3. Search for a Student Record
o Allow users to search for a specific student's details using their
unique ID.
4. Delete a Student Record
o Enable the removal of a student's record based on their ID.
5. File Storage (Optional)
o Save data to a file for persistence between program executions.
o Load data from the file at startup.
Code Structure
The project is structured as follows:
1. Data Structure:
The program uses a struct to store student details.
typedef struct {
char name[50];
int id;
char subject[50];
float grade;
} Student;
Implementation
Below is the complete implementation:
#include <stdio.h>
#include <string.h>
typedef struct {
char name[50];
int id;
char subject[50];
float grade;
} Student;
Student students[MAX];
int count = 0;
void addStudent() {
if (count >= MAX) {
printf("\nMaximum student limit reached!\n");
return;
}
count++;
printf("\nStudent record added successfully!\n");
}
void viewStudents() {
if (count == 0) {
printf("\nNo records found!\n");
return;
}
printf("\nID\tName\t Subject\tGrade\n");
for (int i = 0; i < count; i++) {
printf("%d\t%-10s\t%-10s\t%.2f\n",
students[i].id, students[i].name, students[i].subject, students[i].grade);
}
}
void searchStudent() {
int searchID;
printf("\nEnter ID to search: ");
scanf("%d", &searchID);
int main() {
int choice;
do {
printf("\nMenu:\n");
printf("1. Add Student\n");
printf("2. View Students\n");
printf("3. Search Student\n");
printf("4. Delete Student\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1: addStudent(); break;
case 2: viewStudents(); break;
case 3: searchStudent(); break;
case 4: deleteStudent(); break;
case 5: printf("\nExiting program. Goodbye!\n"); break;
default: printf("\nInvalid choice! Please try again.\n");
}
} while (choice != 5);
return 0;
}
Enhancements and Future Scope
The project can be further improved by:
1. Adding File Handling: Save and load records using files for data
persistence.
2. Input Validation: Ensure valid input values for ID and grades.
3. Sorting Records: Display records sorted by name or grade.
4. Graphical Interface: Use libraries like GTK+ or ncurses for better
UI.
Conclusion
This project demonstrates the application of essential programming
concepts in C. It provides a solid foundation for managing structured data
and solving real-world problems programmatically. Students can expand
upon this system to incorporate more advanced features and explore
deeper aspects of programming.