title: Unusual Behaviour of printf statement inside loop
body: <p>I am new to programming world, I made a program to check if the given number is prime or not, but it is showing unusual behaviour.<br><br>
  My code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  void main()
  {
      int n;
  
      printf(&quot;Enter n:&quot;);
      scanf(&quot;%d&quot;, &amp;n);
  
      for (int i = 0; i &lt;= n - 1; i++)
      {
          if (n % i == 0)
          {
              printf(&quot;n is not a prime number!&quot;);
              break;
          }
          if (i == n - 1)
          {
              printf(&quot;n is prime!&quot;);
          }
      }
  }
  </code></pre>
  <p>Expected Output:</p>
  <pre><code>Enter n:5
  n is prime!
  </code></pre>
  <p>Actual Output:</p>
  <pre><code>Enter n:5
  </code></pre>
  <p>Reference <a href="https://i.stack.imgur.com/rwciI.png" rel="nofollow noreferrer">Screenshot</a> <br>
  Using VS Code and MinGW.
  Thanks in Advance</p>