0% found this document useful (0 votes)
15 views7 pages

Document

This C++ program implements a student management system using a linked list data structure. The program allows the user to add, search, modify, and delete student records from the linked list. The main menu displays options to perform these operations and clears the screen before each operation. Student records contain name, discipline, roll number, and section fields.

Uploaded by

Mr Mudassir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views7 pages

Document

This C++ program implements a student management system using a linked list data structure. The program allows the user to add, search, modify, and delete student records from the linked list. The main menu displays options to perform these operations and clears the screen before each operation. Student records contain name, discipline, roll number, and section fields.

Uploaded by

Mr Mudassir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

#include<iostream>

#include<Windows.h>

#include<cctype>

#include<string>

Using namespace std;

Bool check = true;

Struct node {

Char name[20];

Char discipline[20];

Int rollNo;

Char section;

Node* next;

} * head, * lastptr;

Void add() {

Node* p = new node;

Cout << “Enter name of student:” << endl;

Cin.ignore();

Cin.getline(p->name, 20);

Cout << “Enter discipline of student:” << endl;

Cin.getline(p->discipline, 20);

Cout << “Enter Roll Number of student:” << endl;

Cin >> p->rollNo;

Cout << “Enter section of student:” << endl;

Cin >> p->section;

p->next = nullptr;
if (check) {

head = p;

lastptr = p;

check = false;

Else {

Lastptr->next = p;

Lastptr = p;

Cout << endl << “Record Entered”;

Cin.ignore();

Cin.get();

Void modify() {

Int roll_no;

Cout << “Enter Roll Number to search:” << endl;

Cin >> roll_no;

Node* prev = nullptr;

Node* current = head;

While (current && current->rollNo != roll_no) {

Prev = current;

Current = current->next;

If (current) {

Node* ptr = new node;

Cout << “Enter name of student:” << endl;


Cin.ignore();

Cin.getline(ptr->name, 20);

Cout << “Enter discipline of student:” << endl;

Cin.getline(ptr->discipline, 20);

Cout << “Enter Roll Number of student:” << endl;

Cin >> ptr->rollNo;

Cout << “Enter section of student:” << endl;

Cin >> ptr->section;

If (prev)

Prev->next = ptr;

Else

Head = ptr;

Ptr->next = current->next;

Current->next = nullptr;

Delete current;

Cout << endl << “Record Modified”;

Else {

Cout << “Record not found”;

Cin.ignore();

Cin.get();

Void search() {

Int roll_no;

Cout << “Enter Roll Number to search:” << endl;


Cin >> roll_no;

Node* current = head;

While (current && current->rollNo != roll_no) {

Current = current->next;

If (current) {

Cout << “\nname: “ << current->name;

Cout << “\nRoll No:” << current->rollNo;

Cout << “\nDiscipline:” << current->discipline;

Cout << “\nSection:” << current->section;

Else {

Cout << “Record not found”;

Cin.ignore();

Cin.get();

Void del() {

Int roll_no;

Cout << “Enter Roll Number to Delete:” << endl;

Cin >> roll_no;

Node* prev = nullptr;

Node* current = head;

While (current && current->rollNo != roll_no) {

Prev = current;
Current = current->next;

If (current) {

If (prev)

Prev->next = current->next;

Else

Head = current->next;

Current->next = nullptr;

Delete current;

Cout << endl << “Record Deleted”;

Else {

Cout << “Record not found”;

Cin.ignore();

Cin.get();

Int main() {

Char x;

Cout << “\t\t ********************************* \t\t\t” << endl;

Cout << “\t\t ****STUDENT MANAGEMENT SYSTEM**** \t\t\t” << endl;

Cout << “\t\t ********************************* \t\t\t” << endl;

Cout << “……………………………………..” << endl;

Cout << “…………………” << endl;

Cout << “…………………………………………………….” << endl;

Cout << “\n\nPress Any Key To Continue . . . .” << endl;


Cin.ignore();

Cin.get();

Do {

System(“cls”);

Cout << “1-Press ‘1’ to add New record:” << endl;

Cout << “2-Press ‘2’ to search a record:” << endl;

Cout << “3-Press ‘3’ to modify a record:” << endl;

Cout << “4-Press ‘4’ to delete a record:” << endl;

Cout << “5-Press ‘5’ to exit:” << endl;

X = cin.get();

Switch (x) {

Case ‘1’:

System(“cls”);

Add();

Break;

Case ‘2’:

System(“cls”);

Search();

Break;

Case ‘3’:

System(“cls”);

Modify();

Break;

Case ‘4’:

System(“cls”);

Del();

Break;
Case ‘5’:

Exit(0);

Default:

Break;

} while (x != ‘5’);

Cin.ignore();

Cin.get();

Return 0;

You might also like