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;
}
-