Kth Node from the end of linked list

my code is not working here is my code https://ide.codingblocks.com/s/286475

i have correcte dthe code but now when i ask or kth element from last it gives me k+1 element https://ide.codingblocks.com/s/286480

i have got my error now its working fine but i cant figure out what should we do when user enters the value of k which is gretaer than the length of the linked list?

When you take k as input. Update k to k%(length of linked list). This will ensure that k is not greater than the length of the linked list.

but suppose length is 4 and user enters k =9 then k%length will give 1 and will give 1 st elemetn from last

i want no element should be returned

So if you want no element to be returned in that case, then first check the length of the linked list.
Now impose another condition that if k > length then print nothing and return from there.

if(k>l){ return; } its giving error

because my function return node* adrsress

So in that case return NULL.

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.