Append in linked list

https://ide.codingblocks.com/s/326614 its showing some error. pls check my code as well wheter its passing test cases or not pls resolve my doubt as soon as possible make changes in my code if possible but pls don’t change the whole code otherwise i won’t be able to understand my mistake. thanks

@shrutikatyal
When k >= n, then according to the question, you do not need to perform any operation and should directly print the list. You are reducing n to zero because of which you again need to find the length of the list again which is inefficient. Thus you should just use a for loop. Secondly, in your insertAtEnd function, the return type should be void but you have used node*. Just change that. In your append function, your return type is node*, inspite of that you are not taking an inputs where you called the function. Also, you didnt update the value of head. Current pointer is the new head.

This is the code.
If my answer was able to clear your query, please mark the doubt as resolved.