0% found this document useful (0 votes)
14 views5 pages

Zeeshan Tayyab BSEE02183142 Section A: Data Structure and Algorithms

The document outlines an assignment for a Data Structure and Algorithms course at the University of Lahore, requiring students to design software to record marks for students repeating the course. The software must utilize data structures such as stacks, queues, and linked lists, with a bonus task of identifying the student with the highest marks. The provided code includes functions for adding and searching student records using a linked list implementation.

Uploaded by

burhannajeeb8
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)
14 views5 pages

Zeeshan Tayyab BSEE02183142 Section A: Data Structure and Algorithms

The document outlines an assignment for a Data Structure and Algorithms course at the University of Lahore, requiring students to design software to record marks for students repeating the course. The software must utilize data structures such as stacks, queues, and linked lists, with a bonus task of identifying the student with the highest marks. The provided code includes functions for adding and searching student records using a linked list implementation.

Uploaded by

burhannajeeb8
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/ 5

The University of Lahore

Department of Electrical Engineering

Course:Data Structure and Algorithms

ZEESHAN TAYYAB
BSEE02183142
Section A

Assignment# 2 (CLO2/PLO3)
CS department of UOL wants to keep a record of students Marks who are repeating the Data Structure
and Algorithm course in Summer 2020. You are required to design a software which takes student name
and Marks in DataStructure Course and inserts the info in a record utilizing the following Data
Structures.

▪ Stack
▪ Queue
▪ Linked list
Bonus Steps:

• Find the student with Maximum marks and print his/her Name and position in linked
list

Code:
#include<conio.h>
#include<iostream>
#include<string>
using namespace std;
bool check = true;
struct node
{
char name[20];
char department[20];
int rollNo;
int marks;

Data Structure Project1/ 4


node *next;
}*head,*lastptr;

void add()
{
node *p;
p=new node;
cout<<"Enter name of student:"<<endl;
gets(p->name);
fflush(stdin);
cout<<"Enter department of student:"<<endl;
gets(p->department);
fflush(stdin);
cout<<"Enter Roll Number of student:"<<endl;
cin>>p->rollNo;
fflush(stdin);
cout<<"Enter marks of student:"<<endl;
cin>>p->marks;
fflush(stdin);
p->next=NULL;

if(check)
{
head = p;
lastptr = p;
check = false;
}
else
{
lastptr->next=p;
lastptr=p;
}
cout<<endl<<"Recored Entered";
getch();
}

void search()
{
node *prev=NULL;
node *current=NULL;
int roll_no;
cout<<"Enter Roll Number to search:"<<endl;
cin>>roll_no;
prev=head;
current=head;
while(current->rollNo!=roll_no)
{
prev=current;
current=current->next;
}

Data Structure Project2/ 4


cout<<"\nname: ";
puts(current->name);
cout<<"\nRoll No:";
cout<<current->rollNo;
cout<<"\nDepartment:";
puts(current->department);
cout<<"\nMarks:";
cout<<current->marks;
getch();
}
int main()
{
char x;
do
{
system("cls");
cout<<"Press '1' to add New record:"<<endl;
cout<<"Press '2' to search a record:"<<endl;
cout<<"Press '0' to exit:"<<endl;
x=getch();
if(x=='1')
{
system("cls");
add();
}
else if(x=='2')
{
system("cls");
search();
}
else if(x=='0')
{
exit(0);
}
else
{
}
}while(x != 27);
getch();
}

Output:

Enter name of student:


Zeeshan
Enter department of student:
EE
Enter Roll Number of student:
142
Enter marks of student:

Data Structure Project3/ 4


85

Recored Entered

Data Structure Project4/ 4


Data Structure Project5/ 4

You might also like