Print the elements of a linked list solution

Print the elements of a linked list solution


Problem Statement

You’re given the pointer to the head node of a linked list and you need to print all its elements in order, one element per line. The head pointer may be null, i.e., it may be an empty list. In that case, don’t print anything!

Source code:

 /*  
  Print elements of a linked list on console   
  head pointer input could be NULL as well for empty list  
  Node is defined as   
  struct Node  
  {  
    int data;  
    struct Node *next;  
  }  
 */  
 void Print(Node *head)  
 {  
  // This is a "method-only" submission.   
  // You only need to complete this method.   
   while(head!=NULL){  
     cout<<head->data<<endl;  
     head = head->next;  
   }  
 }  

3 comments :

  1. I had the same problems and spent a lot of money to solve it. Thank you! I wish your blog be successful, that's w hy visit custom writing paper and see what our professionals propose you to do!

    ReplyDelete
  2. This is actually quite interesting. The code you came up with is totally useful and it really shows your creativity level :) Thank you for posting!

    ReplyDelete
  3. Top 100 online Situs Judi Slot Game Casinos UK | CasinoNow
    List 카지노사이트 of Sites that Accept Situs Judi Slot Games · Slots Empire · MyStake · GameSpin · Slots LV · Pinnacle.🤝 Lady Luck casinosites · MrLuck.

    ReplyDelete