hey, i was writing this program for complex number calc and when i run it ,it never returns me the right values..

so can u plz make necessary changes where i m wrong..

YEAH AND ONE IMP THING TO TELL U I M BEGINNING WITH POINTERS AND I LITERALLY SUCK AT IT!!!

so here's the code:

```
# include <cmath>
class Complex
{
private:
double i, r;
public:
int Set_C(double,double);
int Get_I();
int Get_R();
int Add(Complex);
int Sub(Complex);
int Mul(Complex);
int Div(Complex);
};
Complex::Set_C(double x,double y)
{
r=x;
i=y;
return 0;
}
Complex::Get_R()
{
return this->r;
}
Complex::Get_I()
{
return this->i;
}
Complex::Add(Complex a)
{
this->r=i+a.i;
this->i=r+a.r;
return 0;
}
Complex::Sub(Complex a)
{
this->r=a.r-r;
this->i=a.i-i;
return 0;
}
Complex::Mul(Complex a)
{
this->r=r*a.r-i*a.i;
this->i=r*a.i+i*a.r;
return 0;
}
Complex::Div(Complex a)
{
this->r=((r*a.r)+(i*a.i))/(pow(r,2)+pow(i,2));
this->i=((r*a.i)-(i*a.r))/(pow(r,2)+pow(i,2));
return 0;
}
```

so this was the CLASS..

```
# include <iostream>
using namespace std;
void main ()
{
Complex c1, c2;
double x, y, s;
char ch='y';
while (ch=='y'||ch=='Y')
{
cout<<"\nInput The Real And Imaginary Number For Complex Number C1:";
cin>>x>>y;
c1.Set_C(x,y);
cout<<"\n\nInput The Real And Imaginary Number For Complex Number C2:";
cin>>x>>y;
c2.Set_C(x,y);
cout<<"1.ADDITION OF TWO COMPLEX NUMBERS."<<"\n\n2.SUBTRACTION OF TWO COMPLEX NUMBERS."<<"\n\n3.MULTIPLICATION OF TWO COMPLEX NUMBERS."<<"\n\n4.DIVISON OF TWO COMPLEX NUMBERS."<<"\n\n5.FOR ALL.";
cout<<"\n\nInput The Option:";
cin >>s;
if(s==1 || s==5)
{
cout<<"\nAddition Of Two Complex Numbers-------------------------------";
c2.Add(c1);
cout<<"\n"<<c2.Get_R()<<" + "<<c2.Get_I()<<"i\n";
}
if(s==2 || s==5)
{
cout<<"\nSubtraction Of Two Complex Numbers----------------------------";
c2.Sub(c1);
cout<<"\n"<<c2.Get_R()<<" + "<<c2.Get_I()<<"i\n";
}
if(s==3 || s==5)
{
cout<<"\nMultiplication Of Two Complex Numbers-------------------------";
c2.Mul(c1);
cout<<"\n"<<c2.Get_R()<<" + "<<c2.Get_I()<<"i\n";
}
if(s==4 || s==5)
{
cout<<"\nDivison Of Two Complex Numbers--------------------------------";
c2.Div(c1);
cout<<"\n"<<c2.Get_R()<<" + "<<c2.Get_I()<<"i\n";
}
if(s > 5)
{
cout<<"\nSELECTION OUT OF RANGE.";
}
cout<<"\nDo You Want To Restart The Calculation(Y for YES & N for NO):";
cin>>ch;
system("cls");
}
}
```

I get confused where to apply this-> pointer and where to not.