Need help fixing this line in my code in C++. This line is meant to multiply two complex numbers and return the answer.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Need help fixing this line in my code in C++. This line is meant to multiply two complex numbers and return the answer.

Post by answerhappygod »

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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply