title: What loop should I use for the Question posted down below?
body: <p>Question is how to get the program to ask for input until a valid choice (4-20) is given by the user? I just need to know how to repeat a question. So if a user inputs the wrong number then it will ask the user to input a valid number until the user enters a correct number between 4-20.</p>
  <pre><code>#include&lt;iostream&gt;
  #include&lt;cstdlib&gt;
  #include&lt;ctime&gt;
  using namespace std;
  int main() {
  int num;        //integer for number
  int roll;       //integer for roll
  srand(time(0)); //seed random number generator
  
  cout &lt;&lt; &quot;You are about to roll a single die&quot; &lt;&lt; endl; 
  cout &lt;&lt; &quot;How many sided die would you like to roll(4-20)? &quot;; 
  cin &gt;&gt; num;
  cin.ignore();
  
  
  roll = 1 + rand() % num;        //mods random number
  if (num &gt;= 4 &amp;&amp; num &lt;= 20) {
      cout &lt;&lt; &quot;You rolled: &quot; &lt;&lt; endl;
      cout &lt;&lt; roll &lt;&lt; endl;
  } 
  
  else
  {
      cout &lt;&lt; &quot;Please play again and enter a number between 4 and 20&quot; &lt;&lt; endl;
      cout &lt;&lt; &quot;Press RETURN to continue...&quot;&lt;&lt;endl;
      cin.get(); 
      cout&lt;&lt;&quot;Exiting&quot;&lt;&lt;endl;
  
  }
  
  
  return 0;
  }
  </code></pre>