title: Queue implementation program in C
body: <p>Ive just started C and I'm trying to do this queue implementation program from my book but it isn't working. Its giving the error that function qfull and qempty are undefined. Even after properly declaring the function its still giving more errors.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;process.h&gt;
  #include &lt;conio.h&gt;
  #define QUEUE_SIZE 5
  
  void main()
  {
      void insert_rear(int, int *, int *);
      void delete_front(int *, int *, int *);
      void display(int *, int, int);
      int choice, item, f, r, q[10];
      /* Queue is empty */
      f = 0; /* Front end of queue*/
      r = -1; /* Rear end of queue*/
      for (;;)
      {
          clrscr();
          printf("\t\t\t Ordinary Queue Operation\n\n");
          printf("\t\t\t 1 …. Push / Insert\n");
          printf("\t\t\t 2 …. Pop / Delete\n");
        printf("\t\t\t 3 …. View / Display\n");
          printf("\t\t\t 4 …. Exit\n\n\n");
          printf("\t\t\t Enter the choice : "); scanf("%d", &amp;choice);
          switch (choice)
          {
              case 1: // push into the queue
                  printf("Enter the item to be inserted : "); scanf("%d", &amp;item);
                  insert_rear(item, q, &amp;r);
                  continue;
           case 2: // pop from the queue
                  delete_front(q, &amp;f, &amp;r);
                  break;
              case 3: // display queue
                  display(q, f, r);
                  break;
              case 4:
                  exit(0);
           default:
                  printf("\t\t\tInvalid Input – Try Again");
          } // end of switch
          getch();
      }// end of for
  } // end of main
  
  
  
  /*******************/
  
  
  
  void insert_rear(int item, int q[], int *r)
  {
      if (qfull(*r)) /* Is queue full ? */
      {
          printf("\t\t\tQueue overflow\n");
          return;
      }
      /* Queue is not full */
      q[++(*r)] = item; /* Update rear pointer and insert a item */
  }
  
  
  
  /*—————————————————————– */
  
  
  
  void delete_front(int q[], int *f, int *r)
  {
      if (qempty(*f, *r))
      {
          printf("\t\t\tQueue underflow\n");
          return;
      }
      printf(" Pop Successfull, element deleted = %d ",q[(*f)++]);
      if(*f&gt; *r)
      {
          *f=0,*r=-1;
      }
  }
  
  
  
  /*********************************************************/
  
  
  
  void display(int q[], int f, int r)
  {
      int i;
      if (qempty(f,r))
      {
          printf("Queue is empty\n");
          return;
      }
      printf("\t\t\t Queue Container\n\n");
      for(i=f;i&lt;=r; i++)
          printf("\t\t\t| %5d |\n",q[i]);
  }
  
  
  
  /**********************************************/
  
  
  
  int qempty(int f, int r)
  {
      return (f&gt;r)?1:0;
      /* returns true if queue is empty otherwise returns false */
  }
  
  
  
  /**********************************************/
  
  
  
  int qfull(int r)
  { /* returns true if queue is full otherwise false */
      return (r==QUEUE_SIZE-1)?1:0;
  }
  </code></pre>