title: Assignment in an 'if' statement. How is the output correct?
body: <p><a href="https://i.stack.imgur.com/wVy9V.png" rel="nofollow noreferrer">Code</a> in case if the image not is visible.</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int fun(int n)
  {
      if(n=4)
          return n;
      else
          return 2*fun(n+1);
  }
  
  int main()
  {
      printf(&quot;%d&quot;, fun(2));
  }
  </code></pre>
  <p>This is the code snippet and the output is given as 4 by the professor.</p>
  <p>How is the output correct?</p>
  <p>Is it possible that n=4 is assigned in the 'if-else' statement as the assignment operator is correct, but the &quot;if&quot; condition will not work as the syntax is wrong and the output will be directly given as 4.</p>