#include
#include
#include
void Insert();
void Del();
void Display();
typedef struct student node;
struct student
{
int rollno;
node *next;
}*front,*rear,*newrec;
void main()
{
clrscr();
int choice=0,n,i;
while(choice!=4)
{
printf("\n==============Menu===============");
printf("\n| 1. Insert Item into the Queue |");
printf("\n| 2. Delete from the Queue |");
printf("\n| 3. Display the Queue Items |");
printf("\n| 4. Exit the Application |");
printf("\n=================================");
printf("\n Enter the Choice :->");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\n HOW MANY ITEMS YOU WANT TO PUSH INTO THE Queue :->");
scanf("%d",&n);
for(i=0;i
newrec->next=NULL;
if(front==NULL)
front=newrec;
else
rear->next=newrec;
rear=newrec;
}
void Del()
{
node *ptr;
ptr=front;
if(front==NULL)
{
printf("\n Queue is underflowing !!!");
return;
}
else
front=front->next;
free(ptr);
}
void Display()
{
node *ptr;
int srno=0;
ptr=front;
if(ptr==NULL)
{
printf("\n Queue is Empty");
return;
}
printf("\n------------------------");
printf("\nSr. No. Record Value ");
while(ptr!=NULL)
{
srno++;
printf("\n %d %d ",srno,ptr->rollno);
ptr=ptr->next;
}
printf("\n------------------------");
}
No comments:
Post a Comment