Zeeshan Tayyab BSEE02183142 Section A: Data Structure and Algorithms
Zeeshan Tayyab BSEE02183142 Section A: 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;
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;
}
Output:
Recored Entered