title: whats the difference between dynamic memory allocation and normal memory allocation?
body: <p>can someone please tell me the difference between the type of memory i am using here in the two given methods 
  because in the first on i am getting out put as this:</p>
  
  <p><code>5--&gt;1893664096--&gt;32766--&gt;-1358605976--&gt;2--&gt;1893664096</code></p>
  
  <p>and in second method i am getting this:-</p>
  
  <p><code>5--&gt;0--&gt;0--&gt;0--&gt;2--&gt;0</code></p>
  
  <p>below are the codes for this:-</p>
  
  <p>Method 1:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  int main()
  {
    int n;
    scanf("%d",&amp;n);
    int arr[n];
    arr[3]=2;
    for(int i=0;i&lt;n;i++)
      printf("--&gt;%d",arr[i]);
    return 0;
  }
  </code></pre>
  
  <p>Method 2:</p>
  
  <pre><code>int main()
  {
    int *a;
    int n;
    scanf("%d",&amp;n);
    a=(int*) malloc(sizeof(int)*n);
    a[3]=2;
    for(int i=0;i&lt;n;i++)
      printf("--&gt;%d",a[i]);
    return 0;
  }
  </code></pre>