title: random number in while loop [C programming]
body: <p>I'm trying to create 2 random numbers (between 0-4 and 0-10) in each time the cycle occurs, but it always give the same number.
  If I run the program multiple times, it gives different numbers, but the while cycle always generates the same 2 numbers.
  thanks.</p>
  
  <pre><code>int random(int range){
      int num;
      srand(time(NULL));
      num = rand() % range;
      return num;
  }
  
  int main(){
  
      int cnt = 0;
      int i;  
      int j;
      while (cnt &lt;= 20) {
          i = random(5);
          j = random(10);
          printf("%d\n",i);
          printf("%d\n",j);
          printf("\n");
          cnt += 1;
      }
      return 0;
  }
  </code></pre>