title: Fibonacci series in C++ : Control reaches end of non-void function
body: <p>while practicing recursive functions, I have written this code for fibonacci series and  (factorial) the program does not run and shows the error "Control reaches end of non-void function" i suspect this is about the last iteration reaching zero and not knowing what to do into minus integers. I have tried return 0, return 1, but no good. any suggestions?</p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iomanip&gt;
  #include &lt;iostream&gt;
  #include &lt;ctime&gt;
  using namespace std;
  
  int fib(int n) {
      int x;
          if(n&lt;=1) {
              cout &lt;&lt; "zero reached \n";
              x= 1;
          } else {
              x= fib(n-1)+fib(n-2);
              return x;
          }
      }
  
  
  
  
  int factorial(int n){
      int x;
      if (n==0){
          x=1;
         }
      else {
              x=(n*factorial(n-1));
              return x;
          }
  
      }
  </code></pre>