18)Write a menu driven program using C for static implementation of queue. -Insert -Delect -Display -Exit


#include<stdio.h>
#include<conio.h>
#define MAX 3
int a[MAX];
int front=-1;
int rear=-1;
void insert();
void del();
void disp();
void main()
{
int ch;
clrscr();
do
{
printf(“\nMenu \n”);
printf(“\n1.INSERT”);
printf(“\n2.del”);
printf(“\n3.disp”);
printf(“\n4.exit”);
printf(“\nEnter ur choice”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:
insert();
break;
case 2:
del();
break;
case 3:
disp();

break;
case 4:
exit(0);
}
}
while(ch!=4);
getch();
}
void insert()
{
int n;
if(rear==MAX-1)
{
printf(“Q is Full”);
}
else
{
if(front==-1)
{
front=0;
}
else
{
rear++;
printf(“\nEnter the Element”);
scanf(“%d”,&n);
a[rear]=n;
}

}
}
void del()
{
if(front==-1)
{
printf(“\nQ is Empty”);
}
else
{
printf(“Deleted Element is %d”, a[front]);
front++;
}
}
void disp()
{
int i;
if(front==-1)
{
printf(“\nQ is Empty”);
}
else
{
for(i=front;i<=rear;i++)
{
printf(“%d->”,a[i]);
}
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s