0% found this document useful (0 votes)
21 views10 pages

Project: Subject: Data Structure Course Code: CS-204 Instructor: Ms. Fakhra Nazir

Uploaded by

Aw Ai S
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)
21 views10 pages

Project: Subject: Data Structure Course Code: CS-204 Instructor: Ms. Fakhra Nazir

Uploaded by

Aw Ai S
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/ 10

Project

Subject : Data structure


Course code: CS-204
Instructor: Ms. Fakhra Nazir

Department: Computer Science

Submitted by
Name: Qandeel Zulfiqar
Roll No: 19010819-074
Class: MSc-cs-(iii)

University of Gujrat
GT Road campus, Gujrat
Problem #01

Code:

#include<iostream>
using namespace std;

bool Check = true;

struct Node
{
string Name;
string F_Name;
int F_No;
int Marks;
Node* next;
Node* prev;
};
struct Node*head, *Last;
void STD(string nm,string fnm,int fno,int m)
{

if (head == NULL)
{
struct Node* newnode = new Node;
newnode->Name = nm;
newnode->F_Name = fnm;
newnode->F_No = fno;
newnode->Marks = m;
newnode->next = newnode->prev = newnode;
head = newnode;
return;
}

Last = head->prev;

struct Node* newnode = new Node;


newnode->Name = nm;
newnode->F_Name = fnm;
newnode->F_No = fno;
newnode->Marks = m;

newnode->next = head;

head->prev = newnode;

newnode->prev = Last;

Last->next = newnode;
}
void Add_STD()
{
Node* p;
p = new Node;

cout << "Enter Student Name: ";


cin >> (p->Name);
cout << "Enter Student Father Name: ";
cin >> (p->F_Name);
cout << "Enter Student Form No.: ";
cin >> p->F_No;
cout << "Enter Student Test Marks: ";
cin >> p->Marks;
p->next = NULL;

if (Check)
{
head = p;
Last = p;
Check = false;
}
else
{
Last->next = p;
Last = p;
}
cout << endl << "Student Added Successfully..!";
}

void Eligibility_STD(){

struct Node* temp;


temp = head;
while (temp->next != head) {
if(temp->Marks>140){
cout<< temp->Name<<temp->F_Name<<temp->F_No;
}
temp = temp->next;
}
}

int Search_STD()
{

struct Node *temp;


temp = head;

int count=0,flag=0,value;
int search;
cout<<"enter file no"<<endl;
cin>>search;

if(temp == NULL)
return -1;
else
{

while(temp->next != head)
{

count++;

if(temp->F_No == search)
{
flag = 1;
count--;
break;
}

temp = temp->next;
}

if(temp->F_No == search)
{
count++;
flag = 1;
}

if(flag == 1)
cout<<"\n"<<search <<" found at location "<< count;
else
cout<<"\n"<<search <<" not found ";
}
}

void Del_STD()
{

if (head == NULL)
return;

struct Node *curr, *prev_1;


curr = head;
prev_1 = NULL;
int key;
cout<<"enter file no"<<endl;
cin>>key;
while (curr->F_No != key) {

if (curr->next == head) {
cout<<"\nThere is no student with file no = "<< key;
return;
}

prev_1 = curr;
curr = curr->next;
}

if (curr->next == head && prev_1 == NULL) {


head = NULL;
free(curr);
return;
}

if (curr == head) {

prev_1 = head->prev;

head = head->next;

prev_1->next = head;
head->prev = prev_1;
free(curr);
}

else if (curr->next == head) {

prev_1->next = head;
head->prev = prev_1;
free(curr);
}
else {
struct Node* temp;
temp = curr->next;

prev_1->next = temp;
temp->prev = prev_1;
free(curr);
}
}

int main()
{

STD("qandil", "zul", 1790, 160) ;


STD("jk","nk",4356,100) ;
STD("qandil","rao",1090,170) ;
STD("genio","zul",2030,150) ;

cout<<endl;
int x;

do
{
cout << "1) Add New Student" << endl;
cout << "2) Search Student" << endl;
cout << "3) Eligible Student" << endl;
cout << "4) Delete Student" << endl;
cout << "0) Exit:" << endl;
cin >> x;
if (x == 1)
{
Add_STD();
}
else if (x == 2)
{
Search_STD();
}
else if (x == 3)
{
Eligibility_STD();
}
else if (x == 4)
{
Del_STD();
}
else
{

}
}
while (x != 0);

return 0;
}

You might also like