次のコードを実行すると、常に浮動小数点例外が発生します。どうすれば修正できますか?
#include <stdio.h>
//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", &num);
printf("Denominator: ");
scanf("%d", &denom);
//Call Function
simplify(&num1, &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;
}