title: Dividing by zero in C
body: <p>When I compile the program: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      int x, y = 0;
  
      x = 1 / y;
      printf("x = %d\n", x);
      return 0;
  }
  </code></pre>
  
  <p>It gives "Floating point exception (core dumped)"</p>
  
  <p>However, when I compile:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void)
  {
      double x, y = 0;
  
      x = 1 / y;
      printf("x = %f\n", x);
      return 0;
  }
  </code></pre>
  
  <p>It prints "x = inf"</p>
  
  <p>Why does it return x as an infinite value if you're using double but returns an error if you're using int?</p>