# Manipulating Array Values

• 08-02-2007
benjamin923
Manipulating Array Values
I'm having trouble figuring out how to manipulate two arrays. The arrays are listed below.

double z1[2];
double z2[2];
z1[0] = a;
z1[1] = b;
z2[0] = c;
z2[1] = d;

*where a,b,c, & d are user inputs. I need to do different operations as separate functions (i.e. adding, subtracting, dividing, multiplying) and then output the results into a separate array. Any help would be greatly appreciated.
• 08-02-2007
MacGyver
Sorry, I don't understand what your end goal is. You need to write functions to perform mathematical operations on arrays? Can you be more specific please?
• 08-02-2007
benjamin923
Yes-to clarify...if I have an array
Code:

```  {a,b} and an array {c,d} I need to write a function to (a+c) + (b+d)```
• 08-02-2007
MacGyver
OK, so what you mean is that adding one array with another array is defined as adding their i+j-th elements together?

ie.

Code:

```Array One: [1, 2, 3] Array Two: [2, 1, 3] Array One + Array Two: [3, 3, 6]```
• 08-02-2007
srindom
You just access them as you wrote:
a = z1[0]
b = z1[1]
c = z2[0]
d = z2[1]
• 08-02-2007
MacGyver
OK, so you need a loop to go through each element if I'm understanding this right. This is trivial.