#include<iostream>

using namespace std;

class complex

{

double real;

double imag;

public:

complex operator/(complex c)

{

double real1,real2,imag1,imag2,divisor;

real1=real;

real2=c.real;

imag1=imag;

imag2=c.imag;

real=(real*c.real)-(imag*(c.imag*-1));

imag=(real1*(c.imag*-1))+(imag*real2);

divisor=(real2*real2)+(imag2*imag2);

real=real/divisor;

imag=imag/divisor;

complex temp;

temp.real=real;

temp.imag=imag;

return temp;

}

void display()

{

cout<<“(“<<real<<“,”<<imag<<“)”<<endl;

}

void set()

{

cout<<“Enter real: “<<endl;

cin>>real;

cout<<“Enter imag: “<<endl;

cin>>imag;

}

};

int main()

{

complex c1,c2,c3;

c1.set();

c2.set();

c1.display();

c2.display();

cout<<“after division: “<<endl;

c3=c1/c2;

c3.display();

system(” pause”);

}

<—–End—–>

Output Will Be:

Enter real:

5

Enter imag:

6

Enter real:

7

Enter imag:

8

(5,6)

(7,8)

after division:

(o.734513,0.0176991)