What is the error in last 3 lines of the if statement

void insertatthemiddle(node*&head, int data , int p)
{
if(head == NULL || p == 0)
{
insertathead(head,data);
}
else if(p > length(head))
{
insertattail(head,data);
}
else
{
int jump = 1;
node *temp = head;
while(jump <= p-1)
{
temp = temp -> next;
jump +=1;
}
node *n = new node(data);
n->next = temp -> next ;
temp -> next = n;
}
return;
}

It must be else if(p >= length(head))
I cannot see any more error in this function. Change the one that i have mentioned and then check.
If still there is error,then please save your complete code on ide.codingblocks.com and share its link.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.