3 test cases giving wrong answer, I have tested it

please check

when k>n then dont return the same list.
lets suppose ip is 1 2 3 4 and k =5
it means is we have to append last 1 i.e. k%n

Still test case -4 is giving run errot- https://ide.codingblocks.com/s/209530

Ya the problem in code is, your are assigning prev->next=NULL but there can be chance that prev=NULL as initialized because the value of n==k