Queueusingstack C
Queueusingstack C
Queueusingstack C
#include<stdio.h>
#include<stdlib.h>
struct stack{
int top;
int size;
int *arr;
}
int isFull(struct stack *stack)
{
if(stack->top==stack->size-1)
{
return 1;
}
else
{
return 0;
}
}
int isEmpty(struct stack *stack)
{
if(stack->top==-1)
{
return 1;
}
else
{
return 0;
}
}
switch (a)
{
case 1:
int data;
printf("Enter the data to be inserted.");
scanf("%d",&data);
if(isEmpty(s1))
{
push(s1,data);
}
else
{
while(!isEmpty(s1))
{
push(s2,pop(s1));
}
push(s1,data);
while(!isEmpty(s2))
{
push(s1,pop(s2));
}
}
break;
case 2:
printf("The element is popped out %d\n",pop(s1));
break;
case 3:
traversal(s1);
break;
case 4:
return 0;
default:
printf("why you failure");
break;
}
}
}