Puzzle 2D9

Add two arrays together to fill in the elements of a third array

[E-6] Write a function that adds corresponding elements of two arrays to form the values for elements of a third array. All three arrays must be the same size and the third array must already exist.


void  add2DArrays( int rows, int cols, int x[rows][cols] , 
                   int y[rows][cols],  int sum[rows][cols]   )
{
 
 
}

Unlike Java and other object-oriented languages, C functions typically change the values of already-existing things (like arrays). The above function expects that main storage for all three arrays has already been allocated. If it has not, strange things will happen.



Previous Page        Answer         Next Page         Home