Page 138 - DCAP407_DATA_STRUCTURE
P. 138

Unit 8:  Queues




                               /*Program of queue using array*/
                               /*insertion and deletion in a queue*/
                               /*insertion and deletion in a queue*/
                               # include <stdio.h>
                               # define MAX 50

                               int queue_arr[MAX];
                               int rear = -1;
                               int front = -1;
                               void ins_delete();
                               void insert();
                               void display();
                               void main()
                               {

                               int choice;
                               while(1)
                               {
                               printf("1.Insert\n");
                               printf("2.Delete\n");
                               printf("3.Display\n");

                               printf("4.Quit\n");
                               printf("Enter your choice : \n");
                               scanf("%d",&choice);
                               switch(choice)
                               {
                               case 1 : insert();
                               break;

                               case 2 : ins_delete();
                               break;
                               case 3: ins_display();
                               break;
                               case 4: exit(1);
                               default:

                               printf("Wrong choice\n");
                               }/*End of switch*/
                                      }/*End of while*/
                                   }/*End of main()*/
                               void insert()





                                        LOVELY PROFESSIONAL UNIVERSITY                          131
   133   134   135   136   137   138   139   140   141   142   143