title: Why won't my program stop looping?
body: <p>My assignment is to use two different kinds of loops (For, While, do While). The task is to ask the user to enter a number between 1 and 10 and then the program will count from 0 to the users number. Also, the program must be able to display an error message and ask the user to enter a number again if the user enters a number outside of 1 through 10. The part of the code with the error message and the prompt to enter a number again is working just fine. However, when I enter a number within the range, it either does nothing or counts from 0 to their number an infinite amount of times and won't stop looping the count. Please help!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  
  {
      //Variables
      int num;
      int zero;
  
      //Explains to the user what the program will do
      printf("This program will count from 0 to a number you pick.\n\n");
  
      //Asks the user to input a value
      printf("Please enter a number (between 1 and 10): \n");
      scanf("%d", &amp;num);
  
  
      //If the correct range was selected by the user
      while ( num &gt;= 1 &amp;&amp; num &lt;= 10 )
      {
              for ( zero = 0; zero &lt;= num; zero++ )
              {
                      printf("%d...", zero);
  
              }
      }
  
      //If a value outside of the accepted range is entered
      while ( num &lt; 1 || num &gt; 10)
      {
              printf("I'm sorry, that is incorrect.\n");
              printf("Please enter a number (between 1 and 10): \n");
              scanf("%d", &amp;num);
      }
  
  
      printf("\n\n\n");
  
      return 0;
  
  
  }
  </code></pre>