Complex Numbers
Implement a new type Complex
that stores the real
number and the imaginary unit (imag
). Both real
and image
should be double
.
Implement the following
functions:
Complex add(Complex a, Complex b);
Complex sub(Complex a, Complex b);
Complex mul(Complex a, Complex b);
Having these functions in place, it becomes possible to add, substract,
and multiply two complex numbers. The mathematical basis for the
implementation is available for addition and
multiplication.
Use these functions in main(.)
to make sure they produce
the correct outcomes for the following combinations:
- 5+5i, 7+i;
- 5+5i, 7-3i;
- 3-2i, 7-3i;
- -5, 7-3i
Name the source file: complex_numbers.c