0% found this document useful (0 votes)
176 views6 pages

Data Structure Project: Student Records

This project involves creating a data structure to store student data using a linked list or binary tree. The data of all students in a class, including roll number, name, age, and gender, can be entered and will persist even after closing the program. The data structure allows searching by roll number, marks, or name. The C++ code provided implements functions to insert new student data by appending to a text file, search the text file by name, and a main function with a menu to insert or search data and exit.

Uploaded by

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

Data Structure Project: Student Records

This project involves creating a data structure to store student data using a linked list or binary tree. The data of all students in a class, including roll number, name, age, and gender, can be entered and will persist even after closing the program. The data structure allows searching by roll number, marks, or name. The C++ code provided implements functions to insert new student data by appending to a text file, search the text file by name, and a main function with a menu to insert or search data and exit.

Uploaded by

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

DATA STRUCTURE AND ALGORITHM

PROJECT

Submitted to - Submitted by-


Dr. Ajmer Singh Name- aryan mandi
(CSE Department) Roll no.-20001001014
Section- CSE A

Topic-
Make following project in any language of your choice ,with following
functionalities in it
1. create a data structure (using Binary tree or linked list) and appropriate
storage of it for later access.
2. Student of all your class with Roll number , name, age, gender be entered (
once entered it must not erase even after power off, close, shut down)
3. You must be able to search data by roll number, by marks or by name.
Code:
#include <bits/stdc++.h>
using namespace std;

struct student
{
string name;
string roll_num;
string age;
string gender;
struct student *next;
};

struct student *first, *last, *point;

void insert()
{

fstream sfile;

[Link]("student_profile.txt", ios::out | ios::app);

cout << "Enter the details of student:" << endl;

string name, roll_num, age, gender;

cout << "Name of the student : ";


cin >> name;
cout << "Roll number of the student : ";
cin >> roll_num;
cout << "Age of the student : ";
cin >> age;
cout << "Gender of the student : ";
cin >> gender;
sfile << name << ", "
<< roll_num << ", "
<< age << ", "
<< gender << " "
<< endl;
}

void search()
{

first = NULL;
last = NULL;
string student_name;

ifstream file("student_profile.txt");

string name;
string roll_num;
string age;
string gender;

while ([Link]())
{
getline(file, name, ',');
getline(file, roll_num, ',');
getline(file, age, ',');
getline(file, gender, '\n');

point = new struct student;


point->next = NULL;
point->name = name;
point->roll_num = roll_num;
point->age = age;
point->gender = gender;

if (first == NULL)
{
first = point;
last = point;
}
else
{
last->next = point;
last = point;
}
}
cout << endl;
cout<<”enter the name of the student you want to search: “;

cin >> student_name;

struct student *temp;


temp = first;

do
{
if (temp->name == student_name)
{
cout << temp->name << temp->roll_num << temp->age <<
temp->gender << endl;
break;
}

temp = temp->next;
} while (!(temp->next == 0));

[Link]();
}

int main()
{
fstream sfile;

[Link]("student_profile.txt", ios::out | ios::app);


int n;
while (n != 4)
{
cout<<"\nData of student :\n 1. insert data of student \n 2. Find the
student \n 3. Exit\n";
cin>>n;
switch(n)
{
case 1:
insert();
break;
case 2:
search();
break;
case 3:
exit(0);
break;
default:
cout<<"Invalid input";
break;
}
}

return 0;
}
Output:

You might also like