//The code has a very strange bug, I'll find it later.
#include
<stdio.h>
#include
<math.h>
double
FloatsDiffDivProduct(double dNumA, double dNumB);
int
main(void)
{
double dNum1, dNum2, dDiff, dProduct;
int sStatus;
printf_s("Enter two floats.\n");
sStatus = scanf_s("%lf %lf", &dNum1, &dNum2);
while (sStatus == 2)
{
dDiff = fabs(dNum1 - dNum2);
dProduct = dNum1 * dNum2;
printf_s("%g\n", dDiff / dProduct);
printf_s("Enter two floats.\n");
sStatus = scanf_s("%lf %lf", &dNum1, &dNum2);
}
//Call function.
printf_s("Enter another two floats.\n");
sStatus = scanf_s("%lf %lf", &dNum1, &dNum2);
printf_s("%d", sStatus);
while (sStatus == 2)
{
FloatsDiffDivProduct(dNum1, dNum2);
printf_s("Enter another two floats.\n");
sStatus = scanf_s("%lf %lf", dNum1, &dNum2);
}
getchar();
getchar();
getchar();
return(0);
}
//Define function.
double
FloatsDiffDivProduct(double dNumA, double dNumB)
{
double dDiff, dProduct, dResult;
dDiff = fabs(dNumA - dNumB);
dProduct = dNumA * dNumB;
dResult = dDiff / dProduct;
return(dResult);
}
哔哔one