title: Printing the Circular linked list
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  
  using namespace std;
  
  struct node
  {
      int data;
      struct node* link;
  };
  
  struct node* front;
  struct node* rear;
  
  void insert()
  {
      struct node*temp;
      temp = (struct node*)malloc(sizeof(struct node));
      cin &gt;&gt; temp-&gt;data;
      if (front == NULL)
      {
          front = rear = temp;
      }
      else
      {
          rear-&gt;link = temp;
          rear = rear-&gt;link;
      }
      rear-&gt;link = front;
  }
  
  
  void del()
  {
      struct node* temp;
      temp = front;
      if (front == NULL)
          cout &lt;&lt; "Underflow";
      else
      {
          front = front-&gt;link;
          free(temp);
      }
      rear-&gt;link = front;
  }
  
  void disp()
  {
      struct node* temp;
      temp = front;
      if (front == NULL)
          cout &lt;&lt; "Empty";
      else
      {
          do
          {
              cout &lt;&lt; temp-&gt;data &lt;&lt; "-&gt;";
              temp = temp-&gt;link;
          } while (temp != front);
  
      }
      rear-&gt;link = front;
  }
  int main()
  {
      int n;
      bool run = true;
      while (run)
      {
          cin &gt;&gt; n;
          switch (n)
          {
          case 1:
              insert();
              break;
          case 2:
              del();
              break;
          case 3:
              disp();
              break;
          case 4:
              run = false;
              break;
          }
      }
      return 0;
  }
  </code></pre>
  
  <p>I am new to the concept.I wrote a code for insertion deletion and display of elements using queue implementing the concept of linked list..The program is working fine without any errors . But when the output is displayed . I need to display the output along with the first element I inserted..E.g: My input is 
  1
  2
  1
  3
  1
  4
  3
  The output is 2->3->4-></p>
  
  <p>but the output I need is 2->3->4->2->
  I want to see the first element again at the last</p>