title: How to create an array in a random and non-repetitive way in C?
body: <p>I'm trying to write a program that can place numbers from 1 to 20 in a random and non-repetitive way to a 20 element array.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  
  int main(void) {
   int i,j,A[20],flag;
      srand(time(NULL)); 
  
      for(i=0; i&lt;20; i++){
          flag=1;
          A[i]=1+rand()%19;
         for(j=0;j&lt;20;j++){
  
             if(A[i]==A[j]){
              flag=0;
               break;
             }
  
          }
          if(flag=0){
              continue;
          }
          else
          printf("%d ",A[i]);
     }
      return 0;
  }
  </code></pre>
  
  <p>It gives repeated output.</p>