# Thread: calculating elements of arrays

1. ## calculating elements of arrays

Hi, can someone help me with this?

I am a student and we're working on this assignment. We are to write a program that declares three two-dimensional arrays, named first, second, and third. Initialize the first array when it is declared.

Calculate each element in the second array by taking 27% of each element in the first array. Use pointer notation in this function. Send the name of the first array and the name of the second array as arguments to the function. This function will not return any value.

Add the first array to the second array and place the sum in the third array. Use array notation in this function. Send the name of the first array, the name of the second array, and the name of the third array as arguments to the function. This function won't return any value.

Use the following data to initialize only the first array in main.
1.0 4.0 7.0 10.0
2.0 5.0 8.0 11.0
3.0 6.0 9.0 12.0

use the #define to set up constants for the number of rows and columns in the array:
#define r 3
#define c 4.

2. So can you do any of your homework at all, or are you completely helpless in this task?

a) trying to do something
b) any answers we give will be more tuned to your specific problems.

3. It looks pretty straightforward:
Code:
```/* Process */
a = someval;
b = a * .27;
c = a + b;```
The principle is the same except you're working with arrays:
Code:
```/* Process */
for ( i = 0; i < r; i++ ) {
for ( j = 0; j < c; j++ ) {
b[i][j] = a[i][j] * .27;
c[i][j] = a[i][j] + b[i][j];
}
}```
Swap out the array notation for pointer notation and you're all set. Try to remember next time that difficult problems only seem that way. Most of the time if you dig down a little bit you'll find that the solution is really very simple.