#include

#include

#define MAX_ARRAY_LENGTH 256

double power(double, unsigned int);

int main(int argc, char** argv) {

double a = atof(argv[1]);

int b = atoi(argv[2]);

double result = power(a, b >> 31 == 0 ? b : -b);

if ((unsigned int) b >> 31 == 1) {

result = 1 / result;

}

printf("%f\n", result);

return 0;

}

double power(double a, unsigned int b) {

switch (b) {

case 0:

return 1.0;

case 1:

return a;

default:

return (b & 1) == 0 ? power(a * a, b >> 1) : power(a * a, b >> 1) * a;

}

}

Could be implemented many ways. I got the feeling that the interviewer wanted to see you approach the problem in multiple ways and demonstrate confidence in your math and recursive skills.