title: In C, are variables declared within a loop, local?
body: <pre><code>    #include &lt;stdio.h&gt;
  
      int a;
  
      void myproc()
      {
          int a = 2;
          while (a == 2)
          {
              int a = 3;
              printf("a = %d\t", a);
              break;
          }
          printf("a = %d\t", a);
      }
  
      int main()
      {
          a = 1;
          myproc();
          printf("a = %d\t", a);
          return (0);
      }
  </code></pre>
  
  <p>I expected the above code to print: a = 3 a = 3 a = 1
  However, it prints: a = 3 a = 2 a = 1 Can someone please provide a valid explanation?</p>