title: Initialize User defined parameters value for Array in C
body: <p>I learned in the text book, that there are only a few ways you can initialize an array.</p>
  <p>Method one:</p>
  <pre><code>int ary[5] = {1,2,3,4,5};
  </code></pre>
  <p>Method two:</p>
  <pre><code>int ary[] = {1,2,3,4,5};
  </code></pre>
  <p>But what if I want to input user defined values into the array. Would this code be ok? Can anyone teach me a better way to do this?</p>
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;conio.h&gt;
  
  int main()
  {
      int i, n;
      printf(&quot;Enter array parameter: \n&quot;);
      scanf(&quot;%d&quot;,&amp;n);
      int a[n]; 
      int b[n];
      
      for(i=0;i&lt;n;i++)
      {
          printf(&quot;Enter value for array a[%d]: \n&quot;,i+1);
          scanf(&quot;%d&quot;,&amp;a[i]);
      }
      n -= 1; 
      for(i=0;i&lt;=n;i++)
      {
          b[i]=a[n-i];
      }
      printf(&quot;Value of array b[] is: \n&quot;);
      for(i=0;i&lt;=n;i++)
      {
          printf(&quot;%d &quot;,b[i]);
      }
      for(i=0;i&lt;=n;i++)
      {
          printf(&quot;\narray b[%d] = %d &quot;,i,b[i]);
      }
      
      getch();
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/qiXSm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qiXSm.png" alt="enter image description here" /></a></p>