title: generate random number in a range c++
body: <p>I'm using the ncurses library to build a game. I'm having trouble generating the correct random numbers. The while loop below  needs to keep generating random numbers until they are between 1 and 45(this is my y-axis limits on the standard screen). I can't figure out what I'm doing wrong because the while loop condition looks fine to me. The problem is that while loop starts running infinitely. Im not doing anything but printing the generated numbers at the end as i just want to see that the correct numbers are generated. can anyone please help me with this problem? The following is my int main. </p>
  
  <pre><code>int main()
  {
  int r,c,x=0;
  initscr();
  raw();
  keypad(stdscr, TRUE);
  noecho();
  //mvprintw(22,45,"&lt;");
  getmaxyx(stdscr,r,c);
  
  int n,n2 = 0;
  
  while((n&lt;1)||(n&gt;45)){
  srand (time(NULL));
  n = rand();
  srand (time(NULL));
  n2 = rand();
  }
  mvprintw(4,10,"First Random Number: %d\n", n);
  mvprintw(5,10,"Second Random number: %d\n", n2);
  
  getch();
  endwin();
  return 0;
  }
  </code></pre>