Write functions multiply_complex and divide_complex to implement the operations of multiplication and division of complex numbers defined as follows:
(a+bi)×(c+di) = (ac−bd) + (ad+bc)i
(a+bi) / (c + di) = (ac+bd) / (c2 + d2) + (bc−ad i) / (c2 + d2)
Program: C
#include <stdio.h>
#include <stdlib.h>
void multiply_complex(double a, double b, double c, double d)
{
double real_mult=(a*c)-(b*d);
double comp_mult=(a*d)+(b*c);
printf("Multiply: %.2lf + %.2lfi\n",real_mult,comp_mult);
}
void divide_complex(double a, double b, double c, double d)
{
double real_div=((a*c)+(b*d))/((c*c)+(d*d));
double comp_div=((b*c)-(a*d))/((c*c)+(d*d));
printf("Division: %.2lf + %.2lfi\n",real_div,comp_div);
}
int main()
{
double a,b,c,d;
printf("Please enter the value of a b c d respectively\n");
scanf("%lf %lf %lf %lf",&a,&b,&c,&d);
multiply_complex(a,b,c,d);
divide_complex(a,b,c,d);
}
I hope it helps.
Thank you
Get Answers For Free
Most questions answered within 1 hours.