You can do this with 32-bit arithmetic. You just have to reduce mod k after every multiplication, to stop the numbers getting too big:
int pow_mod_k (int a, int b, int k) {
int result = 1 ;
while (b--) {
result *= a ;
result %= k ;
}
return result ;
}
As jadhachem points out in a comment, you can make this faster by using a squaring ladder. But for such small numbers, it would hardly be worth it.