Need help fixing this line in my code in C++. This
line is meant to multiply two complex numbers and return the
answer.
in .h file
in .cpp file
// Multiplies two complex numbers and returns this
answer.
Complexno Complexno::mult(const Complexno& num2) {
Complexno answer;
answer.real = real * num2.real - complex *
num2.complex;
answer.complex = real * num2.complex + complex *
num2.real;
return answer;
}
Outputs:
Enter the first complex number :
Enter the real part of the complex number : 1
Enter the imaginary part of the complex number : 3
Enter the second complex number :
Enter the real part of the complex number : 1
Enter the imaginary part of the complex number : -3
(1.0 + 3.0i) * (1.0-3.0i) = (10.00.0i)
Result needs to be
I think I didn't FOIL correclty? Not sure but thank you for your
help
Need help fixing this line in my code in C++. This line is meant to multiply two complex numbers and return the answer.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am