0% found this document useful (0 votes)
5 views

C Project

Uploaded by

adityaagarwal388
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

C Project

Uploaded by

adityaagarwal388
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Final Assessment Test – Winter 2023-24 Freshers - June 2024

Maximum Marks: 100 Duration: 3 Hours

Course Code:CSE2014 Course Title: Data Structure & Algorithm

Date: 07/06/2024 School: Slot: D2+TD2+TDD2

Project Report

Reg no with names: Aditya Agarwal 23BCB7086


Pranay Rajesh 23BCB7023

Project Title: Student Record Management System

1. Description about the project


This project is a simple Student Record Management System implemented in C programming
language. Here's a description of its features and functionalities:

1. Add a Student Record: This feature allows the user to input information about a new
student, including their name, registration number, and grade. The system assigns a unique
ID to each student.

2. View All Student Records: Users can view a list of all the student records currently
stored in the system. It displays each student's ID, name, registration number, and grade.

3. Search for a Student Record: This feature enables users to search for a specific
student record by entering the student's name. If a match is found, the system displays the
student's information.

4. Delete a Student Record: Users can delete a student record from the system by
entering the ID of the student they wish to remove.

5. Exit: This option allows the user to exit the program.


The system uses a combination of an array (`studentArray`) and a linked list (`StudentNode`)
to manage student records. The array stores student records in a fixed-size array, while the
linked list provides dynamic memory allocation for efficient insertion and deletion of records.

Overall, this Student Record Management System provides basic functionalities for
managing student information, such as adding, viewing, searching, and deleting records.
2 Code
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define MAX_STUDENTS 100

#define NAME_SIZE 50

#define GRADE_SIZE 5

#define REGISTRATION_SIZE 15

// Define a structure to represent a student

typedef struct {

int id;

char name[NAME_SIZE];

char grade[GRADE_SIZE];

char registrationNumber[REGISTRATION_SIZE];

} Student;

// Declare an array to store student records

Student studentArray[MAX_STUDENTS];

// Variable to keep track of the number of students currently stored

int studentCount = 0;

// Define a structure for a node in a linked list of students

typedef struct StudentNode {


Student student;

struct StudentNode* next;

} StudentNode;

// Declare a pointer to the head of the linked list

StudentNode* studentHead = NULL;

// Function to add a new student record

void addStudent() {

if (studentCount < MAX_STUDENTS) {

// Create a new student

Student newStudent;

newStudent.id = studentCount + 1;

printf("Enter student name: ");

scanf(" %[^\n]s", newStudent.name);

printf("Enter registration number: ");

scanf(" %[^\n]s", newStudent.registrationNumber);

printf("Enter grades: ");

scanf(" %[^\n]s", newStudent.grade);

// Add the student to the array

studentArray[studentCount++] = newStudent;

// Create a new node for the linked list

StudentNode* newNode =
(StudentNode*)malloc(sizeof(StudentNode));

newNode->student = newStudent;

newNode->next = studentHead;
studentHead = newNode;

printf("Student record added successfully!\n");

} else {

printf("Student record list is full!\n");

// Function to view all student records

void viewStudents() {

StudentNode* current = studentHead;

while (current != NULL) {

printf("ID: %d\n", current->student.id);

printf("Name: %s\n", current->student.name);

printf("Registration Number: %s\n", current-


>student.registrationNumber);

printf("Grade: %s\n\n", current->student.grade);

current = current->next;

// Function to search for a student record by name

void searchStudent() {

char name[NAME_SIZE];

printf("Enter student name to search: ");

scanf(" %[^\n]s", name);


StudentNode* current = studentHead;

int found = 0;

while (current != NULL) {

if (strstr(current->student.name, name)) {

printf("ID: %d\n", current->student.id);

printf("Name: %s\n", current->student.name);

printf("Registration Number: %s\n", current-


>student.registrationNumber);

printf("Grade: %s\n\n", current->student.grade);

found = 1;

current = current->next;

if (!found) {

printf("No student records found with the name '%s'\n", name);

// Function to delete a student record by ID

void deleteStudent() {

int id;

printf("Enter student ID to delete: ");

scanf("%d", &id);

StudentNode* current = studentHead;

StudentNode* prev = NULL;


// Find the node with the given ID

while (current != NULL && current->student.id != id) {

prev = current;

current = current->next;

if (current != NULL) {

// Remove the node from the linked list

if (prev == NULL) {

studentHead = current->next;

} else {

prev->next = current->next;

// Free the memory allocated for the node

free(current);

printf("Student record deleted successfully!\n");

} else {

printf("Student record not found!\n");

int main() {

int choice;

// Display the menu and prompt for user input until they choose to exit

do {

printf("\nStudent Record Management System\n");

printf("1. Add a Student Record\n");

printf("2. View All Student Records\n");

printf("3. Search for a Student Record\n");


printf("4. Delete a Student Record\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("Exiting...\n");

break;

default:

printf("Invalid choice! Try again.\n");

} while (choice != 5);

return 0;

}
3. OUTPUT

You might also like