A function for adding arrays
in
Programming Questions
•
3 years ago
I need to solve 2 problems for a class and just realized that I have no clue how to do it and need to have it done by tomorrow morning.
Here is the one I cannot figure out:
Create a function that takes as input two arrays of the same size and returns a new array which is the pairwise sum of both input arrays.
Number one I believe I solved::
Create a function that takes as input an array of integers and returns the average of the array as the outcome.
float result;
float value;
void setup (){
value = avarege(1,2,3,4);
println (value);
}
float avarege ( int x1, int x2, int x3, int x4) {
result = (x1 + x2 + x3 + x4) / 4 ;
return (result);
}
****
Please, I would really, really appreciate some help or even the solution (as I am really stressing out with other stuff as well at the moment.)
You would be doing me a huge favor.
Regards
P.
Here is the one I cannot figure out:
Create a function that takes as input two arrays of the same size and returns a new array which is the pairwise sum of both input arrays.
Number one I believe I solved::
Create a function that takes as input an array of integers and returns the average of the array as the outcome.
float result;
float value;
void setup (){
value = avarege(1,2,3,4);
println (value);
}
float avarege ( int x1, int x2, int x3, int x4) {
result = (x1 + x2 + x3 + x4) / 4 ;
return (result);
}
****
Please, I would really, really appreciate some help or even the solution (as I am really stressing out with other stuff as well at the moment.)
You would be doing me a huge favor.
Regards
P.
1