title: Generate random numbers without repetition in C
body: <p>The below result can generate random numbers but repetition of numbers still occurs. Guess there's smtg wrong  within the <em>if else</em> statement?</p>
  
  <p>ADDITIONAL:<br/>
  The question is:
  <strong>Generate the entries as random numbers and repeatedly make new numbers until a legal entry value is found.</strong><br/>
  Hence, swapping of elements is not the solution for this.</p>
  
  <pre><code>int x = 0, y = 0, input[20], current, temp;
  
  main(){
      srand((unsigned)time(NULL));
  
      for (x = 0; x &lt; 20;x++){
          input[x] = rand() % 20 + 1;
  
          for (y = 0; y &lt; 20; y++){
              if (input[x] == input[y]){
                  if (y != x){
                      input[x] = rand() % 20 + 1;
                      y = 0;
                  }
              }
          }
  
      }
  
      for (x = 0; x &lt; 20; x++){
          printf("Input[%d]: %d\n", x + 1, input[x]);
      }
  
      getch();
  }
  </code></pre>