Circular Queue Array in Data Structure used C Language.

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