Only some test cases running

int main() {
int l1,k;
cin>>l1;

node* a = NULL;
makelist(a,l1);
cin>>k;
k%=l1;
if(k != 0 )
lastknode(a,k);
print(a);
return 0;

}

update the code in int main()
since the k ( the length that can be appended at the end of the list ) can be greater than the size of the linked list so take modulo
k%=len ;
if(k != 0 ) has to be checked if in the lastKnode function u have not added the boundary condition so its better to check it in main

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.