Create three arrays of 20 integers each. Fill in two arrayswith data, leaving th
ID: 3618975 • Letter: C
Question
Create three arrays of 20 integers each. Fill in two arrayswith data, leaving the third blank. From main, pass thesethree arrays into a function. Inside the function, add the value ofeach array element and store it in the third.third_array[i] = second_array[i]+ first_array[i]
Back in main, print out the value of every element in thethird/sum array. Excellent output on this assignment might showsomething like:
Array 1 + Array 2 = Array 3 5 + 3 = 8 10 + 4 = 14 etc third_array[i] = second_array[i]+ first_array[i] Array 1 + Array 2 = Array 3 5 + 3 = 8 10 + 4 = 14 Array 1 + Array 2 = Array 3 5 + 3 = 8 10 + 4 = 14
Explanation / Answer
please rate - thanks since you appear to be learning functions, I did it all infunctions #include using namespace std; void add(int[],int[],int[]); void fill(int[]); void print(int[],string); int main() {int a[20],b[20],c[20]; fill(a); fill(b); add(a,b,c); print(a,"Array 1"); print(b,"Array 2"); print(c,"Results of Array 1 + Array 2"); system("pause"); return 0; } void fill(int a[]) {int i; for(i=0;iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.