Not able to print the input of LINKED LISTS

I am not able to print the input I will be getting

In line 32, it should be while(tail->next!=NULL)
This is because when it was while(tail!=NULL), tail would become NULL at the end of the loop
And to reach the last node of the linked list, its should be while(tail->next!=NULL)