Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

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

This c program implements a queue data structure in a student information system. The user can enqueue new student data, dequeue existing data, and display the queue. The program uses dynamic memory allocation and includes functions for input, insertion at the end, deletion from the start, and displaying the queue.

Typology: Exercises

2011/2012

Uploaded on 07/30/2012

dhanvantari
dhanvantari 🇮🇳

2

(2)

51 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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;