creating a recursive function that will print out a number to a power

im trying to create a recursive function that i can call on in order to take a user inputed base and exponent and give final answer this is what i have but im completely lost after this i dont even know how to continue any help is appreciated this is what i have so far

[code}#include <iostream>
using namespace std;
int Exp(int x,int y){
if(base <= 1 || exp == 0) return 1;
if(exp == 1) return base;
int main(){
int number, exp;
double base;
cout << "Base: ";
cin >> base;
cout << "Exp: ";
cin >> exp;
cout << "Ans: " << Exp(base, exp) << endl;
return 0;

after i set the base situations im not sure how to get the function to make the function take the base to the exponent recursively any help is appreciated
Last edited on
"base" does not exist in your function. Also you're missing braces and spacing everywhere.

Edit your post and put [code] before your code and [/code] after it.
#include <iostream>

int main()
    std::cout << "Hello, World!" << std::endl;
Last edited on
i thought that i could declare the variable before the function is called in the main program and im not sure what you mean by code
Topic archived. No new replies allowed.