Modular exponentiation problem

Given a, b and c, we need to compute (a^b)%c. In my code 6/10 testcases are not passing. Can you please look into my code?

The method you were using would give you a tle.
I have updated the code https://ide.codingblocks.com/s/288343

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.

Can you please explain the logic of your power function?

It uses a binary exponentation method.
I am giving a link to Errichto’s video .https://www.youtube.com/watch?v=L-Wzglnm4dM
It is really easy and helpful to understand.