Preview:
//print in the given order as first the value is printed and then a call is made to the next node

void Display(struct Node *p){
  if (p!= NULL){
    printf("%d", p->data);  //first print
    Display(p->next);       //call next
  }
}

//print in reverse order as first the call is made and then the values are printed

void Display(struct Node *p){
  if (p!= NULL){
    Display(p->next);          //call next
    printf("%d", p->data);     //then print
  }
}
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter