title: Floating-point exception from fraction simplification program in C
body: <p>When I run the following code, I always get a floating-point exception.  How can I fix it?</p>
  
  <pre><code>    #include &lt;stdio.h&gt;
  
      //Global Variables
  
      int num, denom, num1, denom1;
  
      void simplify(int *numerator, int *denominator);
  
      int main () {
  
      //Prompt User as to what program is
      printf("Fraction Simplifier\n");
      printf("===================\n");
  
      //Ask User for Numerator and Denominator
      printf("Numerator: ");
      scanf("%d", &amp;num);
      printf("Denominator: ");
      scanf("%d", &amp;denom);
  
      //Call Function
      simplify(&amp;num1, &amp;denom1);
  
      //Display final output
      printf("%d / %d = %d / %d", num, denom, num1, denom1);
  
      return 0;
      }
  
      //Simplify function
      void simplify(int *numerator, int *denominator)
      {
  
      num = num1;
      denom = denom1;
  
      num1 = num1 / num1;
      denom1 = denom1 / num1;
      num1 = *numerator;
      denom1 = *denominator;
  
      }
  </code></pre>