Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MAIN FUNCTION: Language is C++ Define a structure Complex, it has two attributes: real, imag (both double type). You have to define functions to add,
MAIN FUNCTION:
Language is C++
Define a structure Complex, it has two attributes: real, imag (both double type). You have to define functions to add, subtract, and multiply two complex numbers. Since complex numbers can be added/multiplied/subtracted with a real number as well, so the add, subtract and multiply functions should be overloaded: one where both operands are Complex numbers, other where first operand is complex and second operand is real. Main function is already given, you have to make it working. A function show will display the complex number is usual way i.e. x+yi Refer to this page for multiplication of complex numbers: https://www.mathsisfun.com/algebra/complex-number-multiply.html Details Sample Input For Custom Testing 25 5 3 10 Sample Output cl+c2: 7+81 cl-c2: -3+2i cl*c2: -5+317 cl+dl: 12+5 i cl-di: -8+51 cl*dl: 20+501 Explanation First input line is c1 = 2+5i, second line is C2 = 5+3i, third line is a real number d1 = 10. The result of addition/subtraction/multiplication are given as output. int main() { Complex cl, c2; cin>>ci.real>>ci.imag; cin>>c2.real>>c2.imag; double dl; cin>>di; coutStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started