title: Using loop to traverse through linked list
body: <p>I was reading about a few basic operations on linked list and I saw two types of loops being used predominantly</p>
  
  <hr>
  
  <pre><code>struct node {
     int data;
     struct node *next;
  }*start=NULL,*tmp;
  </code></pre>
  
  <p>The first loop was of the form</p>
  
  <pre><code>for(tmp=start;tmp-&gt;next!=NULL;tmp=tmp-&gt;next);
  </code></pre>
  
  <p>Using the above loop, now the <code>tmp</code> pointer points towards the last node in the list</p>
  
  <p>The second loop was of the form</p>
  
  <pre><code>tmp=start;
  while(tmp!=NULL)
  {
       // do something
  }
  </code></pre>
  
  <p>I think that both of them do the same work, but I'm not sure. Is there any difference?</p>