QUEUE IMPLEMENTATION (ALL OPERATION)

607

QUEUE IMPLEMENTATION (ALL OPERATION)

DaTA STRUCTURE

#include<conio.h>
#include<stdio.h>
#define N 5

int queue[N]={0};
int rear=0,front=0;

void insert(void);
void del(void);
void disp(void);
void cre(void);

void main()
{
int user=0;
clrscr();
do
{
clrscr();
printf(“\nTHE SIZE OF QUEUE IS = %d”,N);
printf(“\n\n 1. INSERT A New Element”);
printf(“\n 2. DELETE A First Element”);
printf(“\n 3. DISPLAY A Queue List/Element”);
printf(“\n 4. CREATE A New Queue Struture”);
printf(“\n 5. EXIT\n\nEnter Your Choice : “);
scanf(“%d”,&user);
switch(user)
{
case 1:
clrscr();
insert();
break;
case 2:
clrscr();
del();
getch();
break;
case 3:
clrscr();
disp();
getch();
break;
case 4:
clrscr();
cre();
getch();
break;
case 5:
clrscr();
printf(“\n\t THANK U”);
getch();
break;
}
} while(user!=5);
}

/*********************Functions********************/
void insert(void)
{
int t;
if(rear<N)
{
printf(“\nENTER A VALUE IN QUEUE : “);
scanf(“%d”,&t);
queue[rear]=t;
rear++;
}
else
{
clrscr();
printf(“\nQUEUE OVERFLOW!!!!!!!!!!!!!!!”);
getch();
}
}
void del(void)
{
int i;
printf(“\n %d gets deleted………”,queue[front]);
queue[front]=0;
front++;//pk
}

void disp(void)
{
int i;
printf(“Queue Elements :\n\n”);
for(i=front;i<rear;i++)
{
printf(“\n\t %d”,queue[i]);
}
}
void cre(void)
{

int t;
printf(“\nENTER A VALUE IN QUEUE :”);
scanf(“%d”,&t);
front=0;
queue[front]=t;
rear=front+1;
}

 

OUTPUT
1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 1
ENTER A VALUE IN QUEUE : 50

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 1
ENTER A VALUE IN QUEUE : 100

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 1
ENTER A VALUE IN QUEUE : 150

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 1
ENTER A VALUE IN QUEUE : 200

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 1
ENTER A VALUE IN QUEUE : 250

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 1
QUEUE OVERFLOW!!!!!!!!!!!!!!!

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 3
Queue Elements :

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
50 gets deleted………

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
50 gets deleted………

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
100 gets deleted………

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
150 gets deleted………

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
200 gets deleted………

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
250 gets deleted………

1. INSERT A New Element
2. DELETE A First Element
3. DISPLAY A Queue List/Element
4. CREATE A New Queue Struture
5. EXIT
Enter Your Choice : 2
QUEUE UNDERFLOW

 

 

 

if you need a Downloadable link once message us on-page you can get at a time.

m.me/bcanotesnepal

This post is posted for not further third-party purposes.

Copyright By:-  Bcanotesneapl

Not allowed to upload these notes to other sites.

Like our Facebook Page https://www.facebook.com/bcanotesnepal/

if you want to download this PDF comment on us we will provide you a downloadable link.

if you like please share this post with your friend who studies in BCA

if you have any query please comment below,

if you like our sites. you can visit again for the latest updates notes of different BCA subjects of Presentation and different topics with assignment questions and solutions.

Don’t forget to like our page and post also share with your friend and having your group.

if you have any questions you can drop or share them with me using the comment box I will try to answer your question.

Like our Facebook Page https://www.facebook.com/bcanotesnepal/

LEAVE A REPLY

Please enter your comment!
Please enter your name here