Testcase 2,3,4, are giving run error ,only testcase 1 is giving correct ,reply ASAP

code : https://ide.codingblocks.com/s/137292

On line number 118, instead of passing k, pass k%n to the function. This is to encounter the cases where value of k is larger than n.

Hope this helps.