Execution of code in else block and after if block
<p>In this code i want to know what is the difference between code executed in else and code executed after if block?</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int digits(int number, int value, int times){
    int counter = times;
    counter++;
    int result = number/value;
    value=value*10;
    if (result != 0){
        digits(number,value,counter);
    }
    return counter;
}

int main() {
    int number,no_of_digit;
    cout &lt;&lt; "Enter the number : ";
    cin &gt;&gt; number;
    no_of_digit = digits(number, 10, 0);
    cout &lt;&lt; "No of digits are : " &lt;&lt; no_of_digit &lt;&lt; "\n";
    return 0;
}
</code></pre>

<p>This code doesn't work properly. It give value 1.
But if i put <code>return counter;</code> in else block it works. Why so?</p>