1. ## Adding arrays with pointers - help

I am trying to figure out how to add two arrays. The thing is i have to use pointer notation to add the two to make a third array. I think I am doing this right - but just like all the other times it doesn't work

Code:
```#include<stdio.h>

int main (void)
{

int array1[9];
int array2[9];
/*int array3[9];*/
int i;

printf ("Please enter ten intergers now.  Seperate each number by a space\n");
for ( i = 0; i < 10; i++) {
scanf ("%d", &array1[i]);
}

printf ("Please enter ten intergers now.  Seperate each number by a space\n");
for ( i = 0; i < 10; i++) {
scanf ("%d", &array2[i]);
}

return 0;
}

{
int array3[9];
int *point2a1 = &array1[];
int *point2a2 = &array2[];
int *point2a3 = &array3[];
int i;

for(i = 0; i < 10; i++,) {
array3[i] = *point2a1[i] + *point2a2[i];
}

return 0;

}```

2. So many problems...

You should really allow for 10 integers since that's what your loops and your prompt calls for:

int array1[10];
int array2[10];

I think you meant for the user to enter all 10 numbers at a time, instead of hitting Enter on each one. So I'd look up how to do scanf for multiple valules, and how to check whether you've gotten all 10.

Function add1and2 has declaration issues. It should be

int add1and2(int array1[], int array2[], int array3[])

Assigning pointers there should be more like

int *point2a1 = array1;
int *point2a2 = array2;
int *point2a3 = array3;

The loop should be more like

for(i = 0; i < 10; i++) {
point2a3[i] = point2a1[i] + point2a2[i];

But since your exercise calls for "pointer notation" instead of array indexing, it should be transformed into

Code:
```for(i = 0; i < 10; i++) {
*point2a3 = *point2a1 + *point2a2;
point2a1++;
point2a2++;
point2a3++;
}```
(not checked for syntax)

And then your main function ought to call add1and2() with the arguments in the right order... then display the results.

3. it seems your concepts are not clear about pointers, or may be you have copied this code from somewhere else.
one thing I would suggest you, have well understanding of each line of you code when ever you write any program.
Code:
```	printf ("Please enter ten intergers now.  Seperate each number by a space\n");
for ( i = 0; i < 10; i++) {
scanf ("&#37;d", &array1[i]);
}

printf ("Please enter ten intergers now.  Seperate each number by a space\n");
for ( i = 0; i < 10; i++) {
scanf ("%d", &array2[i]);
}```
alternatively you can also write

Code:
```    for ( i = 0; i < 10; i++) {
scanf ("%d", (array1+i));
}```
make a concept, scanf() function always put the given value at the given address in the given format.
here array1 --- gives the base address of array1. hence scanf() will put the value at this location which finally will be value of first element. and (array1+i) means putting the value at each next location till the array size;

Code:
`	/*int add1and2 (array3[9]);*/`
as according to add1and2() definition, it supposed to pass three arguments like this

with this, compiler understand that the base addresses(address of first elements) of arrays are being passed which may further be iterated through its each element.

Code:
`int add1and2 (array1[], array2[], array3[])`
you should rather write
Code:
`int add1and2 (int array1[], int array2[], int array3[])`
the formal arguments need to be defined fully;

Code:
```	int *point2a1 = &array1[];
int *point2a2 = &array2[];
int *point2a3 = &array3[];```
applying subscript operator only means you are assigning the address of unknown entity.
you should rather write
Code:
`int *point2a1 = &array1[0];`
or
Code:
`int *point2a1 =array1;`

Code:
```	 for(i = 0; i < 10; i++,) {
array3[i] = *point2a1[i] + *point2a2[i];
}```
you code is write though, however it doesn't make any sense if you dont understand what you have written;

Code:
`array3[i] = *point2a1[i] + *point2a2[i];`
can be understood as

Code:
`*(array3+i) = *(*(point2a1+i)) + *(*(point2a1+i)) ;`
means, you are pointing to the same value two times using * operator. although this is not a error prone but it is senseless too.