title: Floating point exception (core dumped) #694457
body: <p>I don't know C++ well, and I don't understand why but this error occurred:
   Floating point exception (core dumped)</p>
  
  <p>I don't know how can I fix it.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main() {
  
      int a = 251;
      int b = 0;
  
      while (a &gt; 0) {
          a = a / 10;
          b++;
      }
      int c = 2;
      int d = 1;
      while (c &lt;= b) {
          d = d * 10;
          c++;
      }
      cout &lt;&lt; d;
      int answer = 0;
      int f = d;
      int g = 1;
      float help;
      while (b &gt; 0) {
          help = (a / (d * g)) *(d / f);
          answer = answer + (int)help;
          a = a % (d * g);
          g = g * (1 / 10);
          f = f * (1 / 10);
          b--;
      }
  
      cout &lt;&lt; answer;
  
      return 0;
  }
  </code></pre>