title: Moving to a while loop if not divisible by 5 in c++
body: <p>I am writing a program for a class where the user inputs a number that is checked to be an even number, checked to see if it is divisible by 5 and if those two are satisfied, the number is then used by a while loop. To clarify, if the number even and is divisible by 5 then code runs, if it is even and divisible by 2 then code runs. The first set of code needs to be in a for loop and the second (divisible by 2) needs to be in a while loop.   </p>
  
  <p>I am stuck on taking the cin and using it in the second set of code, the first set wants to manipulate it first.</p>
  
  <p>Any help figuring this out would be great!</p>
  
  <p>Code:  </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;    
  #include &lt;iomanip&gt;
  
  using namespace std;
  
  int main ()
  {
      system ("color F0");
  
      int number = 0, countIf = 0,countWhile = 0, i=0;
  
      cout &lt;&lt; "Please enter a positive integer or zero to quit: ";
      cin &gt;&gt; number;
      cin.ignore();
  
      if (number &lt; 0 || number%2 != 0)
          cout &lt;&lt; "Error: The integer entered was either not positive or a zero. Try again." &lt;&lt; endl;
  
      //else if (number%5 || (number%2) = 0)
  
      for (number%5; countIf &lt; number; countIf +=5)
      {
          i = number / 10;
          i += countIf;
          cout &lt;&lt; i &lt;&lt; " ";        
      }
      cin.ignore();
  
      while (countWhile &lt;= i &amp;&amp; i%2) 
      {
          int x = 0;
          cout &lt;&lt; x &lt;&lt; " ";
          x += 2;
      }
  
      system ("pause");
      return 0;
  }
  </code></pre>