PROGRAM :
#include<stdio.h>
int top1=-1;
int last1=-1;
int top2=-1;
void push(int s1[], int f);
void display(int s1[]);
void enque(int s1[],int x);
void deque(int s1[],int s2[]);
void pop(int s2[]);
void pore(int s2[],int s1[],int x);
int main()
{
int a,b,s1[100],s2[100];
while(1)
{
printf(" \n\n 1--enque \n 2--deque \n 3--display \n 4--exit \n");
scanf("%d",&a);
switch(a)
{
case 1:
printf(" \n enter the vlue to be insert ");
scanf("%d",&b);
enque(s1,b);
break;
case 2: deque(s1,s2);
break;
case 3: display(s1);
break;
case 4: exit(0);
default : printf(" \n wrong choice ");
}
}
}
void deque(int s1[],int s2[])
{
int flag;
if(top1!=-1)
{
flag=12;
pore(s2,s1,flag);
pop(s2);
flag=21;
pore(s2,s1,flag);
return ;
}
else
{
printf("\n queue is empty ");
}
}
void pore(int s2[],int s1[],int x)
{
if(x==21)
{
while(top2!=-1)
{
top1=top1+1;
s1[top1]=s2[top2];
top2=top2-1;
}
}
else if(x==12)
{
while(top1!=-1)
{
top2=top2+1;
s2[top2]=s1[top1];
top1=top1-1;
}
}
}
void pop(int s2[])
{
printf("\n deleted item is %d",s2[top2]);
top2=top2-1;
}
void enque(int s1[], int x)
{
push(s1,x);
}
void push(int s1[], int x)
{
if(top1!=100)
{
top1=top1+1;
s1[top1]=x;
}
else
{
printf("\n queue is full ");
}
}
void display(int s1[])
{
if(top1!=-1)
{
last1=0;
printf("\n");
while(top1+1!=last1)
{
printf(" %d",s1[last1]);
last1++;
}
}
else
printf(" \n queue is empty ");
}
#include<stdio.h>
int top1=-1;
int last1=-1;
int top2=-1;
void push(int s1[], int f);
void display(int s1[]);
void enque(int s1[],int x);
void deque(int s1[],int s2[]);
void pop(int s2[]);
void pore(int s2[],int s1[],int x);
int main()
{
int a,b,s1[100],s2[100];
while(1)
{
printf(" \n\n 1--enque \n 2--deque \n 3--display \n 4--exit \n");
scanf("%d",&a);
switch(a)
{
case 1:
printf(" \n enter the vlue to be insert ");
scanf("%d",&b);
enque(s1,b);
break;
case 2: deque(s1,s2);
break;
case 3: display(s1);
break;
case 4: exit(0);
default : printf(" \n wrong choice ");
}
}
}
void deque(int s1[],int s2[])
{
int flag;
if(top1!=-1)
{
flag=12;
pore(s2,s1,flag);
pop(s2);
flag=21;
pore(s2,s1,flag);
return ;
}
else
{
printf("\n queue is empty ");
}
}
void pore(int s2[],int s1[],int x)
{
if(x==21)
{
while(top2!=-1)
{
top1=top1+1;
s1[top1]=s2[top2];
top2=top2-1;
}
}
else if(x==12)
{
while(top1!=-1)
{
top2=top2+1;
s2[top2]=s1[top1];
top1=top1-1;
}
}
}
void pop(int s2[])
{
printf("\n deleted item is %d",s2[top2]);
top2=top2-1;
}
void enque(int s1[], int x)
{
push(s1,x);
}
void push(int s1[], int x)
{
if(top1!=100)
{
top1=top1+1;
s1[top1]=x;
}
else
{
printf("\n queue is full ");
}
}
void display(int s1[])
{
if(top1!=-1)
{
last1=0;
printf("\n");
while(top1+1!=last1)
{
printf(" %d",s1[last1]);
last1++;
}
}
else
printf(" \n queue is empty ");
}