Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using c programming language.. define a structured type with real and imaginary

ID: 3609612 • Letter: U

Question

using c programming language..
define a structured type with real and imaginary parts to representa complex number. implement a menu-driven program that will firstallow us to enter two complex number by entering their components,separated by whitespace, in the order real1imag1 real2 imag2. thenpresent a menu with options to add, subtract, multiply or divide.display the input and the result after each operation. write fourfunctions to perform the complex operations defined next, andinstall them in an array of functions that can be called using themenu selection. these functions should accept two structuredarguments, do the computations, store the answer in a local complexvariable, and return the value of the variable. in these formulas,C1, C2 are two complex numbers: C1= a+bi and C2=c+di.
C1 + C2 = (a+c) + (b+d)i
    C1 - C2 = (a-c) +(b-d)i
    C1 x C2 = (ac-bd) +(ad+bc)i
    C1 / C2 = [(ac+bd) +(bc-ad)i]/(c2+d2)


Explanation / Answer

please rate - thanks your on your own for division, I have to get to work. messageme if you have a problem with it #include #include #include #include class Complex {public: void Inputc(); void Outputc(); Complex operator+(Complex x); Complex operator-(Complex x); Complex operator*(Complex x); private: float real,imag; }; Complex Complex::operator + (Complex x) {Complex temp; temp.real=real+x.real; temp.imag=imag+x.imag; return(temp);} Complex Complex::operator - (Complex x) {Complex temp; temp.real=real-x.real; temp.imag=imag-x.imag; return(temp);} Complex Complex::operator *(Complex x) {Complex temp; temp.real=(real*x.real)-(imag*x.imag); temp.imag=(imag*x.real)+(real*x.imag); return(temp);} void Complex::Inputc(void) {char i,paren,comma,trash; scanf("%c%f%c%f%c%c",&paren,&real,&comma,&imag,&i,&paren); trash=getchar();} void Complex::Outputc(void) {printf("(%.2f,%.2fi) ",real,imag);} int main() {char choice,trash; Complex a,b,c; printf("enter a complex number pair such as (5.1,2.3i):"); //cin>>a; a.Inputc(); printf("enter a complex number pair such as (5.1,2.3i):"); //cin>>b; b.Inputc(); printf("enter choice: (a)dd, (s)ub,(m)ult:"); choice=getchar(); trash=getchar(); switch (choice) {case'a':c=a+b;            break; case's': c=a-b;          break; case'm':c=a*b;          break; default: printf("error");} //cout