Phone keypad(recursion)

code: https://ide.codingblocks.com/s/117890
in the above code,is there any alternative of for loop? Can we avoid for loop used for k and use recursion to iterate over different values of k?

No, there is no other way to iterate over different values of k. You need to use for loop only.