code link: https://ide.codingblocks.com/s/234021
Only three test cases are getting passed
@siddharth9k9 hey use mod in pow function also.
Modify the statements as
ans = ((ans%p)*(ans%p))%p;
.
.
.
ans=((ans%p)*(a%p) )%p;
.
.
return ans%p
If this resolves your doubt mark it as resolved,