Find length of singly linked list by R4R Team

Example-
Linked list is : 8->5->1->7
Length is : 4

Following is the function that calculate the length of the linked list:

void length(struct node *ptr)
{
int len=0;
while(ptr!=NULL)
{
len++;
ptr=ptr->link;
}
return len;
}

-

-In this program, we pass first Node address.




Leave a Comment: