campo-sirio/gfm/demo13.c

36 lines
627 B
C
Raw Normal View History

#include <stdio.h>
#include "gm.h"
void ErrorHandler(int,int);
int main(void);
void ErrorHandler(code,ref)
int code,ref;
{
char serr[15],sfun[32];
ErrorName(serr, code);
FunctionName(sfun, ref);
printf("%s error in function %s\n",serr,sfun);
}
int main()
{
DEC da, *a=&da, db, *b=&db, dc, *c=&dc, *p;
SetMathErrVector(ErrorHandler);
ZeroDecimal(a);
ZeroDecimal(b);
ZeroDecimal(c);
dprintf("First number: ");
dscanf("%.2t",a);
dprintf("Second number: ");
dscanf("%.2t",b);
p = DivideDecimalAndRound(c,a,b,2);
if (p)
dprintf("%t / %t = %t\n",a,b,c);
else
dprintf("Division failed.\n");
return 0;
}