title: Catching exception: divide by zero
body: <p>The following code does not catch an exception, when I try to divide by 0. Do I need to throw an exception, or does the computer automatically throw one at runtime?</p>
  
  <pre><code>int i = 0;
  
  cin &gt;&gt; i;  // what if someone enters zero?
  
  try {
      i = 5/i;
  }
  catch (std::logic_error e) {
  
      cerr &lt;&lt; e.what();
  }
  </code></pre>