Write this program in C++: Write the Complex class that allows to operate with complex numbers. This class will store the real and imaginary value
Write this program in C++:
Write the Complex class that allows to operate with complex numbers. This class will store the real and imaginary value of the complex number in member variables, as well as provide overloaded operators to perform the most common operations with said numbers. A constructor with parameters will be necessary to be able to initialize the values of the attributes.
Given the numbers: z1 = (a, b) and z2 = (c, d), implement the operations:
Displays the 5 operations for two input complex numbers.
Note1: In the difference the operator must be -
Note2: There is a bug in the product. The second element must be ad+bc
Note 3: For the scalar part, the * operator cannot be used again (select any other that has not been used). In the example I used %.
Complex operator % (float k){ // the second element is of type float while the first is an object of class Complex
Total complex(1,1);
total.real = real*k;
total.img = img*k;
return total;
= . Suma: Z1 + Z2 = (a + c,b+d) Diferencia: Zn + Z2 = (a -c,b-d) Producto: 21 22 = (ac bd , ad bc) : ac + bd -ad + bc 21 22 c +6 c +6 Producto por un escalar: k_z = (ka,kb) = Divisin: 1 - (not beStep by Step Solution
There are 3 Steps involved in it
Step: 1
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