Recursion, Recursions, Recursions, how cruel art thou.....j/k
#include <iostream>
// objective: to get a number and then a power and return answer
using namespace std;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
ULONG GetPower (USHORT number, USHORT power);
int main()
{
USHORT number, power;
double answer;
cout<<"Enter a number:";
cin>>number;
cout<<"To what power?";
cin>>power;
answer=GetPower(number, power);
cout<<number<<"to the"<<power<<"th power is"<< answer<<endl;
int x;
cin>>x;
return 0;
}
ULONG GetPower (USHORT number, USHORT power)
{
if (power==1)
return number;
else
return (number*GetPower (number, power -1 ));// I am not sure at what
// this function is saying here
/* I understand that the number is being multiplied by
GetPower but I just don't understand what the GetPower function exactly does if you multiply number times power -1 or what, because I really don't understand where the definition for this one is at. Please help
}