title: These two code snippets are similar but show different results
body: <p>first code snippet</p>
  <pre><code>void insert_last(Node* head,int new_data)
  {
      Node* new_node = new Node();
      new_node-&gt;data = new_data;
      new_node-&gt;next = NULL;
  
      if(head == NULL)
      {
          head = new_node;
          return;
      }
      Node *cur = NULL;
      cur = head;
  
      while(cur-&gt;next!=NULL)
      {
          cur = cur-&gt;next;
      }
      cur-&gt;next = new_node;
  }
  </code></pre>
  <p>and the second one :</p>
  <pre><code>void insert_last(Node** head,int new_data)
  {
      Node* new_node = new Node();
      new_node-&gt;data = new_data;
      new_node-&gt;next = NULL;
  
      if(*head == NULL)
      {
          *head = new_node;
          return;
      }
      Node *cur = NULL;
      cur = *head;
  
      while(cur-&gt;next!=NULL)
      {
          cur = cur-&gt;next;
      }
      cur-&gt;next = new_node;
  }
  </code></pre>
  <p>The class is called Node with two data members</p>
  <ol>
  <li>data (type=int)</li>
  <li>*next (type = Node)</li>
  </ol>
  <p>What is the reason that these two code snippets show different results when they are called and which one to use ?</p>