0

hey!i was tryinn to write this complex number addition and i dunno where this garbage value it is pickin from :-/....

m gettin mad over this because first time such a simple program has got me all over :icon_mad:....

so here's the code:

```
# include <iostream>
using namespace std;
# include <cmath>
class Complex
{
private:
double i, r;
public:
Complex()
{
i=r=0;
}
void SetC(double x, double y)
{
r=x;
i=y;
}
void A(Complex a,double x,double y)
{
Complex c;
c.r=r+a.r;
c.i=i+a.i;
x=c.r;
y=c.i;
}
};
void main ()
{
Complex c1, c2;
double x, y, re=0, im=0;
cout<<"\nInput The Real And Imaginary Number For Complex Number C1:";
cin>>x>>y;
c1.SetC(x,y);
cout<<"\nInput The Real And Imaginary Number For Complex Number C2:";
cin>>x>>y;
c2.SetC(x,y);
cout<<"\nThe Addition Of Two Complex Numbers Is As Follows:";
c2.A(c1,re,im);
cout<<re<<"+"<<im<<"i";
}
```

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting