struct Complex {
float real;
float imaginary;
};
void displayComplex(Complex n);
Displays complex number n in the format: real + i imaginary, where real is n’s real part and imaginary is n’s imaginary part
Complex addComplex(Complex a, Complex b);
Returns a complex number whose real part is the addition of the real parts of complex numbers a and b, and whose imaginary part is the addition of the imaginary parts of complex numbers a and b, i.e., returns Complex c where [login to view URL] = [login to view URL] + [login to view URL], and [login to view URL] = [login to view URL] + [login to view URL]
Complex subtractComplex(Complex a, Complex b);
Returns a complex number whose real part is the difference of the real parts of complex numbers a and b, and whose imaginary part is the difference of the imaginary parts of complex numbers a and b, i.e., returns Complex c where [login to view URL] = [login to view URL] - [login to view URL], and [login to view URL] = [login to view URL] - [login to view URL]
Complex multiplyComplex(Complex a, Complex b);
Returns a complex number whose value is the complex product of complex numbers a and b, e.g., if a = (x + iy) and b = (u + iv), then this function returns Complex c = (xu - yv) + i(xv + yu)
void tryToSetComplexByValue(Complex a, float real, float imaginary);
Attempts to change the real and imaginary parts of complex argument a, i.e., this function tries to change the value of the original variable passed into parameter a by setting [login to view URL] = real and [login to view URL] = imaginary. Although a’s values will change, the original variable will not because this function is using pass by value. The parameter a is only a copy of the original variable. Make sure you understand why this function fails
void setComplexByReference(Complex &a, float real, float imaginary);
Successfully changes the real and imaginary parts of complex argument a, i.e., this function changes the value of the original variable passed into parameter a by setting [login to view URL] = real and [login to view URL] = imaginary. The original variable is actually changed since the function is receiving a reference to the original variable. Whatever this function does to the local reference variable a, happens to the original variable passed in since it is being passed in by reference. Make sure you understand why this version of the function works, where the pass by value version did not
void setComplexByPointer(Complex *a, float real, float imaginary);
This version of the function also succeeds in changing the original values of the complex variable passed into a. Variable a is being passed by reference as a pointer to the original variable. To manipulate the original variable, use pointer dereferencing syntax: a->real = real, and a->imaginary = imaginary. Make sure you understand why these last two versions work, where the pass by value did not
Here is a sample output of the program
3 + i2
1 + i4
4 + i6
2 - i2
-5 + i14
3 + i2
4 + i5
5 + i6
Hello sir ,
Consider it done
I will provide implementation for the following functions :-
voiddisplayComplex(Complex n);
Complex addComplex(Complex a, Complex b);
Complex subtractComplex(Complex a, Complex b);
Complex multiplyComplex(Complex a, Complex b);
voidtryToSetComplexByValue(Complex a, float real, float imaginary);
voidsetComplexByReference(Complex &a, float real, float imaginary);
voidsetComplexByPointer(Complex *a, float real, float imaginary);
and run the test to match the output ,
Regards
I have understood what is required in this project clearly. As I am a good C++ programmer it only take maximum 2 hrs to complete perhaps even lesser time. You will receive the running C++ project no errors no warnings.I plan to complete the task in an hour and keep an hour or less to review for any errors not handled in the first hour. Please hire me I will accurately and quickly finish this job. Please free to contact to discuss further details.