create a complex number calculator, your calculator should be able to compute the following:
addition of 2 numbers
subtraction of 2 numbers
multiplication of 2 numbers
division of 2 numbers
computation of the conjugate of a complex number z
Sample run:
Press a for addition, b for subtraction, c for multiplication, d for division, e for conjugate, or any other key to exit: a
enter a complex number: 25
Enter a complex number: 18
(2+5i)+(1+8i)=(3+13i)
To represent a complex number, use an array of two elements. Eg float z|2|; here z|0| corresponds to the real part and z|1| corresponds to the imaginary part of the complex number. Your program should include the following functions:
1) void read_complex(float *z)
2) void print_complex(float *z)
3) void add_complex(float *z, float *z2, float *z3) //z3 z1|z2
4) void sub_complex(float *z1, float *z2, float *z3)//z3 z1-z2
5) void mul_complex(float *z1, float *z2, float *z3)//z3 z1*z2
6) void div_complex(float *z1, float *z2, float *z3)//z3 z1/z2
7) void conj_complex(float *z) //z=conj(z)
I don't knkow what the * means before the z, or what I'm supposed to do with it. My professor doesn't exactly teach, yet expects us to do this.



LinkBack URL
About LinkBacks


