int main(int argc, char** argv) { /* struct fr-add testadd; testadd.nom1 = 1; testadd.nom2 = 2; testadd.den1 = 1; testadd.den2 = 4; */ struct fraction first = {3, 4}; struct fraction second = {1, 5}; struct fraction result = fr_add(first, second); printf("add %i / %i\n", result.nom, result.den); result = fr_sub(first, second); printf("sub %i / %i\n", result.nom, result.den); result = fr_mul(first, second); printf("mul %i / %i\n", result.nom, result.den); result = fr_div(first, second); printf("div %i / %i\n", result.nom, result.den); return (EXIT_SUCCESS); }
int main(void) { gcd_test(); fraction a = {3, 8}; fraction b = {4, 11}; printf("\nTwo fractions, a: 3/8 and b: 4/11\n"); fraction added = fr_add(a, b); printf("Result of addition: %d/%d\n", added.nominator, added.denominator); fraction substracted = fr_sub(a, b); printf("Result of substraction: %d/%d\n", substracted.nominator, substracted.denominator); fraction multiplied = fr_mul(a, b); printf("Result of multiplication: %d/%d\n", multiplied.nominator, multiplied.denominator); fraction divided = fr_div(a, b); printf("Result of division: %d/%d\n", divided.nominator, divided.denominator); }