title: Need help to store integer values from a loop into an array
body: <p>I want to list all the factors of a number into an array. So, here's my try at it.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #define n1 10
  int main()
  {
       int n,i,j,a[n1];
       printf("Enter num: ");
       scanf("%d",&amp;num);
       for(i=1;i&lt;n;i++){
          if(n%i==0){
             for(j=0;j&lt;n;j++)
  </code></pre>
  
  <p>I don't know how to proceed from here. I'm confused. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #define n1 10
  int main()
  {
          int n,i,j,a[n1];
          printf("Enter number : ");
          scanf("%d",&amp;n);
          j = 0;
          for(i=1;i&lt;n;i++){
                  if(n%i==0)
                          a[j++] = i;
          }
          printf("The factors of the number are: ");
          for(j=0;j;j++)
                  printf("%d\n",a[j]);
  }
  </code></pre>