new to programming here and i keep getting the error message, \'incompatible types, int cannot be converted to int []\', the question is to add R1& R2 together if they are o
Your code is broken in many several ways, at least:
int []sumArray
should be `int sumArray[0].int *sumArray = new int[10]
sumArray
is an array so to set an element of it use sumArray[index] = ...
So this may be better:
public int *arrayAdd(int[] R1, int[] R2) {
if( R1.length!= R2.length) {
return nullptr;
}
int *sumArray= new int[R1.length];
for(int i=0; i< R1.length; i++) {
sumArray[i] = R1[i]+ R2[i];
}
return sumArray;
}
After question editing
If you want to sum two arrays, element by element, then a single loop is sufficient...