Question: We want to expand our ability to compute with complex numbers in C + + , specifically to divide complex numbers. Write a main.cpp file
We want to expand our ability to compute with complex numbers in C specifically to divide complex numbers. Write a main.cpp file containing a main function that will read in three complex numbers, z z and z from the shell. Calculate z from zzzz
output it to the shell, and also output its absolute value.
This will require writing functions to add, divide, and take the absolute value of complex numbers. For the absolute value, use z sqrta b
For dividing two complex numbers, use the following formula for z zz
:aaabbab
baabbab
where a
and b
are the real and imaginary components respectively. Add the required code to the attached files. Generic operations on complex numbers, such as add, divide, and absolute value, should be contained in LabExcomplex.cpp The recipes prototypes should be added to LabExcomplex.h Note that this file already contains the definition of the complex struct. Finally, the LabExmain.cpp function should contain everything else reading inputs from the shell, calculating z and its absolute value, and printing the results to the shell. Your program should be able to exactly reproduce the following output:
Enter real and imag parts of z:
Enter real and imag parts of z:
Enter real and imag parts of z:
zj
z
When your code can reproduce this example, the TA or I will test your code with a different set of numbers.
Note: Do not use the builtin complex library in this exercise.
Note: Use the following files as a start for this exercise. There are comments for where to add code. To compile the project with these files, run g LabExcpp to create the executable. This will avoid name conflicts with the previous exercise.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
