In your recursive call you hardcoded numbers so it will just run forever. Also, you need to be doing things with the previous function returns. Putting
return power(x,n-1);
will just return x, regardless of the value for n.
Thank you! It worked! Can you help me out with this one also? This is my function. I need to write a recursive function to print a number digit by digit, seperated by spaces.
#include <iostream>
using namespace std;
int printNumber(int x) {
if (x <10) return x;
return printNumber(x % 10);