//Queue implementation using array #include #include int f,r; void qinsert(int *q,int max) { int item; if(r==max-1) printf("\nThe queue is full\n"); else { printf("\nEnter the item you want to insert :"); scanf("%d",&item); r++; q[r]=item; } if(f==-1) f++; } void qdelete(int *q) { int item; if(f==-1) printf("\nThe queue is empty\n"); else { item=q[f]; printf("\nThe deleted item is : %d\n",item); f++; } if(f>r) f=r=-1; } void display(int *q) { int i; if(f==-1) printf("\nThe queue is empty\n"); else { printf("\nThe element of stack are :\n"); for(i=f;i<=r;i++) printf ("%d ",q[i]); } } int main (void) { int q[20],max,ch; printf("STACK IMPLEMENTAION USING ARRAY--------------\n"); printf ("\nEnter the size of stack : "); scanf("%d",&max); f=-1; r=-1; while(1) { printf("\nEnter\n1. Qinsert\n2. Qdelete\n3. Display\n4. Exit\n"); scanf("%d",&ch); switch(ch) { case 1: qinsert(q,max); display(q); break; case 2: qdelete(q); display(q); break; case 3: display(q); break; case 4: exit(0); default: printf("WRONG INPUT"); } } return 0; }