title: Recursive function causes stack overflow
body: <p>I have the following task: </p>
  
  <blockquote>
    <p><strong>Write a program that asks for a number and a power. Write a recursive
    function that takes the number to the power. For example, if the
    number is 2 and the power is 4, the function will return 16.</strong></p>
  </blockquote>
  
  <p>I wrote a program and there are no errors when I compile it, but when I start the program and enter a value gives an error saying "Stack Overflow". I suppose my recursive function became infinite but I have no idea how to write it in other way.</p>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  int powpow(int number);
  
  int main(){
      cout&lt;&lt;"Enter number:";
      int x;
      cin&gt;&gt;x;
      cout&lt;&lt;"The result of ("&lt;&lt;x&lt;&lt;" * "&lt;&lt;x&lt;&lt;") * "&lt;&lt;x*x&lt;&lt;" is: "&lt;&lt;powpow(x);
      system("pause");
      return 0;
  }
  int powpow(int number){
      int result = number*number;
      return powpow(result);
  }
  </code></pre>