title: Return value in If-else statement - C++
body: <p>The below code prints:</p>
  
  <pre><code>5
  </code></pre>
  
  <p>Why does it print 5? Also if it returns 5 why it doesn't print "James"? I do not understand the below code. If I delete the else word it prints -1. However shouldn't it return a default value?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int fonk()
  {
      int a = 5, b = 3;
      int c = a*b;
      if(c &gt;10)
      {
          if( a&lt;b &amp;&amp; a &gt;0)
          {   cout &lt;&lt;"James";
          return a;
          }
  
          else if(b&lt;0)
          {
              return b;
          }
  
      }
      else return -1;
  
  }
  
  int main()
  {
      int x = fonk();
      cout &lt;&lt; x;
  }
  </code></pre>