Docsity

C Implementation of a Queue in a Student Information System, Exercises of Data Structures and Algorithms

Toggle sidebar
bg1
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
struct stu
{
char reg[30];
char name[30];
float marks;
struct stu *next;
};
int choice=0,srn; struct stu *current,*p,*first,*last;char key[30];
void input (void);
void insert_end (void);
void del_start (void);
void display (void);
void main ()
{
first=NULL;
last=NULL;
clrscr();
while (choice!=4)
{
clrscr();
cout<<"\n\t\tImplementing QUEUE in student information system.\n\n\nEnter
one of the following options:\n\n\t\t- To ENQUEUE a node press:\t1\n\t\t-
- To DEQUEUE a node press:\t2\n\t\t- To display the QUEUE:\t\t3\n\t\t- To
Exit press:\t\t\t4\n";
cin>>choice;
switch(choice)
{
case 1: /*To ENQUEUE New Data*/
insert_end(); getch();
break;
case 2: /*To DEQUEUE DATA*/
del_start(); getch();
break;
case 3: /*To Display*/
display(); getch();
break;
default:
cout<<"\nYou entered the WRONG choice!! Enter again\n";
}
}
}
void input (void)
{
current=new stu;
docsity.com
pf3

Partial preview of the text

Download C Implementation of a Queue in a Student Information System and more Exercises Data Structures and Algorithms in PDF only on Docsity!

#include<stdio.h> #include<conio.h> #include<iostream.h> struct stu { char reg[30]; char name[30]; float marks; struct stu next; }; int choice=0,srn; struct stu current,p,first,*last;char key[30];

void input (void); void insert_end (void); void del_start (void); void display (void);

void main () { first=NULL; last=NULL; clrscr(); while (choice!=4) { clrscr(); cout<<"\n\t\tImplementing QUEUE in student information system.\n\n\nEnter one of the following options:\n\n\t\t- To ENQUEUE a node press:\t1\n\t\t-

  • To DEQUEUE a node press:\t2\n\t\t- To display the QUEUE:\t\t3\n\t\t- To Exit press:\t\t\t4\n"; cin>>choice; switch(choice) { case 1: /To ENQUEUE New Data/ insert_end(); getch(); break;

case 2: /To DEQUEUE DATA/ del_start(); getch(); break;

case 3: /To Display/ display(); getch(); break;

default: cout<<"\nYou entered the WRONG choice!! Enter again\n"; }

} }

void input (void) { current=new stu;

current->next=NULL; cout<<"\n\n\nEnter Registration # of the student:\t"; cin>>current->reg; cout<<"Enter Name of the student:\t"; cin>>current->name; cout<<"Enter Marks of the student:\t"; cin>>current->marks; }

void insert_end (void) { input(); if(first==NULL) { first=last=current; } else { last->next=current; last=current; } }

void display (void) { p=first;srn=1;

if(p==NULL) { cout<<"\nThere is no DATA in the list\n"; } else { while (p!=NULL) { cout<<"\n\n Student #: "<<srn; cout<<"\n\n\tRegistration number:\t"<<p->reg; cout<<"\n\tName:\t"<<p->name; cout<<"\n\tMarks:\t"<<p->marks<<"\n"; p=p->next;srn++; } } }

void del_start (void) { if(first==NULL) { cout<<"\nThere is no DATA in the list\n"; } if(first==last) { delete(p); first=last=NULL;