/* 17.Вычислить произведение двух обыкновенных дробей. Ответ дать в виде обыкновенной и в виде десятичной дробей. Числители и знаменатели относятся к целому типу данных. */ #include #include typedef struct Fraction { int up; int down; } fraction; void printSumFraction(fraction fraction_1, fraction fraction_2) { int a = fraction_1.up; int b = fraction_1.down; int c = fraction_2.up; int d = fraction_2.down; /* a c - * - b d */ printf("%2d %2d %2d * %2d %2d\n", a, c, a, c, a*c); printf("-- * -- = ------------ = -- = %.3lf\n", (double)(a*c)/(b*d)); printf("%2d %2d %2d * %2d %2d\n", b, d, b,d, b*d); } int main() { fraction first; fraction second; printf("Enter a b c and d: "); scanf("%d %d %d %d", &first.up, &first.down, &second.up, &second.down); printSumFraction(first, second); return 0; }