calculator in c++ adding function
<p>So my program makes a random <code>(x,y)</code> arrays, what i want to do is to make <code>x</code> a real number and <code>y</code> imaginary number and add them:
my main program</p>

<pre><code>    #include "complx.h"                          
    int main(){
    const int n = 2;
    Complex a[n];                          
    getData(a,n);
    printArray(a,n);
    isort(a,n);
    printArray(a,n);
    complex_sum(a,n);
    return 0;
}
</code></pre>

<p>it also prints and arranges the arrays, but what I am interested in is how to add the arrays, when for example I would use 4 arrays <code>(x,y)(x,y)(x,y)(x,y)</code>.</p>

<p>this is how i get a random numbers</p>

<pre><code>    void getData(Complex a[],int n){
    int  i;
    srand(time(0)); //If comment this out, get same sequence with each run.      
    for(i=0; i&lt;n; i++){
        a[i].x = rand()%3;  //3 and 10 are just for testing isort                
        a[i].y = rand()%10;
    }
    return;
}
</code></pre>

<p>and here is how i'm trying to add it:</p>

<pre><code>void complex_sum(Complex a[], int n){
    for (int i=0; i&lt;n; i++)
      cout&lt;&lt;"("&lt;&lt;a[i].x+a[i].x&lt;&lt;")";
    cout&lt;&lt;endl;
    return;
</code></pre>

<p>I am stuck on how to add <code>(x,y)(x,y)= x+yi</code></p>

<p>thanks</p>
