0% found this document useful (0 votes)
7 views

Queue Using Arrays

Uploaded by

eloziiopfoze
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Queue Using Arrays

Uploaded by

eloziiopfoze
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

/*queue using arrays */

#define MAX 10
int q[MAX];
int rear=0;
int front=0;
int full=0;
int empty=1;

void ins(int);
void print(void);
int del(void);

void main(void)

{ int opt,ch,y;
clrscr();
do
{
clrscr();
printf("\n1. Insert\n");
printf("\n2. Delete\n");
printf("\n3. Print\n");
printf("\n4. Exit\n");
printf("\n\n\t Enter your Choice\n");
scanf("%d",&opt);

switch(opt)
{
case 1:
printf("\nEnter item to insert \n");
scanf("%d", &y);
ins(y);
break;
case 2:
y=del();
printf("Deleted item is : %d" ,y);
break;
case 3:
printf("\nThe Given List is\n");
print();
}
printf("\n Continue 1/0");
scanf("%d",&ch);
}while(ch==1);
}
void print(void)
{
int i;
for(i=front; i<rear; i++)
printf("%d ," ,q[i]);
}

void ins(int x)
{

if(full)
{
printf("\nQueue Full");
return;
}
else
{
q[rear]=x;
rear++;
empty=0;
if(rear==MAX)
full=1;
}
return;
}

int del(void)
{ int x;

if(empty)
{
printf("\nQueue is Empty");
exit(0);
}
else
{
x=q[front];
front++;
full=0;
if(front==rear)
empty=1;
}
return(x);
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy