Ok. I tried some more. This is what i got.
Code:
#include <iostream>
#include <stdlib.h>
float sum;
int count = 1;
float myFunc(unsigned short int x, unsigned short int y);
int main()
{
unsigned short int x = 0;
unsigned short int y = 0;
float z;
std::cout<<"Write a exponent: ";
std::cin>>x;
std::cout<<"\nNow write the number: ";
std::cin>>y;
sum = y;
z = myFunc(x,y);
std::cout<<"\n the answer is:" << z;
system("pause");
}
float myFunc(unsigned short int x, unsigned short int y)
{
if(count==x)
return sum;
else{
count++;
sum = sum * y;
return(myFunc(x,y));
}
}
It works. But it just seams so , i dont know, uncorrect. I seams like i use a method that is not what the author of my book intended.
Any comments?