Output of this program in this picture undersatand this code and try it yourself
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us
/* http://native-code.blogspot.com */
#include<stdio.h>
#include<conio.h>
#define MAX 20
int f,r,q[MAX];
int isempty();
int isfull();
int del();
void insert(int);
void display();
void main()
{
int k,ch,d;
k=ch=d=0;
f=-1;r=-1;
while(1)
{
printf("/* http://native-code.blogspot.com */");
printf("\n\n1: Insert\n2: Delete\n3: Display\n4: EXIT\n");
scanf("%d", &ch);
switch(ch)
{
case 1:
if(isfull()==0)
{
printf("Enter element:\n");
scanf("%d", &k);
insert(k);
}
else
printf("Overflow\n");
break;
case 2:
if(isempty()==0)
{
d=del();
printf("Deleted number is: %d\n",d);
}
else
printf("Underflow\n");
break;
case 3:
display();
printf("\n");
break;
case 4:
exit(0);
default:
printf("Wrong choice.\n");
}
}
}
void insert(int k)
{
if(isempty())
r=f=0;
else
r++;
q[r]=k;
}
int del()
{
int temp;
temp=q[f++];
if(f>r)
f=r=-1;
return(temp);
}
int isfull()
{
if(r==(MAX-1))
return(1);
else
return(0);
}
int isempty()
{
if(f==-1 && r==-1)
return(1);
else
return(0);
}
void display()
{
int i;
for(i=f; i<=r; i++)
printf("%d ", q[i]);
}
/* http://native-code.blogspot.com */
Try this code in your computer for better understanding. Enjoy the code. If you have any Question you can contact us or mail us

Post a Comment