NAME : Anurag Bhardwaj ROLL NO : 13 COURSE : BCA 1ST YEAR Q- Write a program to implement a queue using an array. #include <stdio.h> #define maxsize 50 void insert(); void delete(); void traverse(); int s [maxsize]; int rear =-1,front=-1; void main () { int choice ,c; do { printf(" enter a choice 1for insert,2for delete,3for traverse,"); scanf("%d",&choice); switch(choice) { case1:insert(); break; case2:delete(); break; case3:traverse(); break; default :printf("choice is invelid"); } printf("do you want to countinue,if yes enter 1,if no enter 0"); scanf("%d",&c); } while(c==1); } void insert() { int item; if (rear ==maxsize-1) { printf(" queue is underflow"); } else if(rear==-1) { rear=rear+1; front=front+1; } { rear=rear+1; } printf("enter element"); scanf("%d",&item); s[rear]=item; } void delete() { if(front ==-1) { printf(" queue is underflow"); } else { if (rear==front) { rear=-1; front=-1; } else { front=front+1; } } } void traverse() { int i; if (front==-1) { printf("queue is underflow"); } else { for(i=front;i<=rear;i++) { printf("%d",s[i]); } } } #include <stdio.h> #define maxsize 50 void insert(); void delete(); void traverse(); int s [maxsize]; int rear =-1,front=-1; void main () { int choice ,c; do { printf(" enter a choice 1for insert,2for delete,3for traverse,"); scanf("%d",&choice); switch(choice) { case1:insert(); break; case2:delete(); break; case3:traverse(); break; default :printf("choice is invelid"); } printf("do you want to countinue,if yes enter 1,if no enter 0"); scanf("%d",&c); } while(c==1); } void insert() { int item; if (rear ==maxsize-1) { printf(" queue is underflow"); } else if(rear==-1) { rear=rear+1; front=front+1; } { rear=rear+1; } printf("enter element"); scanf("%d",&item); s[rear]=item; } void delete() { if(front ==-1) { printf(" queue is underflow"); } else { if (rear==front) { rear=-1; front=-1; } else { front=front+1; } } } void traverse() { int i; if (front==-1) { printf("queue is underflow"); } else { for(i=front;i<=rear;i++) { printf("%d",s[i]); } } }