title: Integer division by zero c++
body: <p>I have to write a program that inputs a number and outputs the highest divisor of it and then the highest divisor of the divisor and so on, until it reaches a prime. But I keep geting :
  "Unhandled exception at 0x00eb1504 in primefinder.exe: 0xC0000094: Integer division by zero."</p>
  
  <p>I guess its the "num%i" that causes it but "i" can't be zero since its "num/2".</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main(){
      unsigned int i=666, num;
      cout &lt;&lt; "Enter number";
      cin &gt;&gt; num;
      while(i&gt;1){
          i = num/2;
          while(num % i == 0){
              i--;
          }
          cout &lt;&lt; i &lt;&lt; endl;
          num=i;
      }
      cin.get();
      return 0;
  }
  </code></pre>