TripAdvisor Interview Question
68 Interview Reviews |
Back to all TripAdvisor Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Engineer at TripAdvisor:
Write a function that raises a number to an exponent in C or Java...
| Tags: | recursive algorithm, c, exponent, base, power See more , See less 8 |
Helpful Question?
Yes |
No
Inappropriate?



0 of 0 people found this helpful
by Interview Candidate:
pow():
int expo(b,e){
int result;
result = pow(b,e);
return result;
}
For loop:
int expo(b,e){
int result;
result = 0;
int x;
for(x=0; x<e; x++){
result = result + b;
}
return result;
}
Recursively:
int expo(b,e){
int x;
x = e;
if(x>0)
return b*expo(b, e-1);
else
return 1;
}