title: Why does a recursive function call need to return a value to calling function?
body: <p>In the following recursive function,</p>
  
  <pre><code>int subtractByOne(int num) {
      printf("%d\n", num);
      if (num == 0)
          return 0;
      return subtractByOne(num - 1);
  }
  </code></pre>
  
  <p>Why is the final return necessary? From what I understand, the base case will always stop the recursion and when control reaches the end of the function (after the recursive call) the function will transfer control to whomever called it without the return.</p>
  
  <p>My knowledge of stack frames and return addresses is weak, but the stack should receive a return address independent of the actual return keyword, no?</p>
  
  <p>Visual Studio 2015 throws a warning about control paths, which I understand. However, during a programming course a grader's IDE would not compile similar code and the professor commented the code was incorrect as opposed to just bad practice. I fixed the code at the time, but never understood why it was incorrect.</p>