title: How do I generate different random numbers in a loop in C?
body: <p>I'm trying to make a dice game that uses 6 dice. I can generate a random number each roll, the problem is that I keep getting that same number (if the generated number is 1, each dice is 1). Is there a way to make it so that each dice doesn't get the same number?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include &lt;time.h&gt;
  
  int main() {
  
      int i;
      int diceRoll;
      srand(time(NULL));
      int r = (rand()%6)+1;
  
      printf("\t\t\t Welcome to Dice Game!\n");
  
      for( i = 0; i &lt; 6; i ++){
          diceRoll= r;
          printf(" %d \n", diceRoll);
      }
  
   return 0;
  
  }
  </code></pre>