Query Array in Data Structure Using C Language

It is a important in your life.please study and in another program.i help improved in your skill.

  1. #  
  2. include < stdio.h >  
  3.     int rear = 0;  
  4. int front = 0;  
  5. int max = 25;  
  6. int queue[100];  
  7. main() {  
  8.         intch;  
  9.   
  10.         void insert();  
  11.         void delete();  
  12.         voidisempty();  
  13.         voidisfull();  
  14.         voidshowqueue();  
  15.   
  16.         do  
  17.   
  18.         {  
  19.             int data;  
  20.             printf("\t*******QUEUE ARRAY********");  
  21.             printf("\t==========================\n");  
  22.             printf("\t 1:insert\n");  
  23.             printf("\t 2:delete\n");  
  24.             printf("\t 3:isempty\n");  
  25.             printf("\t 4:isfull\n");  
  26.             printf("\t 5:show queue\n");  
  27.             printf("\t 7:stop\n");  
  28.             printf("\t===========================\n");  
  29.             printf("enter your choice\n");  
  30.             scanf("%d", & ch);  
  31.   
  32.             switch (ch) {  
  33.                 case 1: // call insert function and BREAK after that  
  34.                     {  
  35.                         insert();  
  36.                         break;  
  37.                     }  
  38.   
  39.   
  40.                 case 2: // call delete function and BREAK after that  
  41.                     {  
  42.                         delete();  
  43.                         break;  
  44.                     }  
  45.                 case 3: // call isempty function and BREAK after that  
  46.                     {  
  47.                         isempty();  
  48.                         break;  
  49.                     }  
  50.   
  51.                 case 4: // call isfull function and BREAK after that  
  52.                     {  
  53.                         isfull();  
  54.                         break;  
  55.                     }  
  56.                 case 5: // call show function and BREAK after that  
  57.                     {  
  58.                         showqueue();  
  59.                         break;  
  60.                     }  
  61.                 case 6:  
  62.                     {  
  63.                         printf("program ended\n");  
  64.                         break;  
  65.                     }  
  66.                 default:  
  67.                     {  
  68.                         printf("enter valid choice");  
  69.                         break;  
  70.                     }  
  71.             }  
  72.         }  
  73.         // end of do while  
  74.         while (ch != 6);  
  75.     }  
  76.     //-------------------------------------------------------------//  
  77. void insert() //function to insert  
  78.     {  
  79.         int data;  
  80.         if (rear == max) {  
  81.             printf("queue is full\n");  
  82.         } else {  
  83.             rear = rear + 1;  
  84.             printf("enter the data\n");  
  85.             scanf("%d", & data);  
  86.             queue[rear] = data;  
  87.             printf("\t inserted data\n");  
  88.         }  
  89.     }  
  90.     //-----------------------------------------------------------//  
  91. void delete() //function to delete  
  92.     {  
  93.         if (rear == front) {  
  94.   
  95.             printf("\nstack is empty");  
  96.         } else {  
  97.             front = front + 1;  
  98.             printf("%d", queue[front]);  
  99.             printf("\n delete data");  
  100.         }  
  101.     }  
  102.     //----------------------------------------------------------//  
  103. voidisempty() //function to isempty  
  104.     {  
  105.         if (rear == front) {  
  106.             printf("queue is empty");  
  107.         } else {  
  108.             printf("queue is not empty");  
  109.         }  
  110.     }  
  111.     //----------------------------------------------------------//  
  112. voidisfull() //function to isfull  
  113.     {  
  114.         if (rear == front) {  
  115.             printf("queue is full");  
  116.         } else {  
  117.             printf("queue is not full");  
  118.         }  
  119.     }  
  120.     //-----------------------------------------------------------//  
  121. voidshowqueue() //function to top of stack  
  122.     {  
  123.         printf("data top of stack=%d\n", queue[rear]);  
  124.     }  
  125.     //------------------------------------------------------------//