Here is my question: Begin this program by creating two arrays of integers, each
ID: 3656480 • Letter: H
Question
Here is my question: Begin this program by creating two arrays of integers, each holding ten elements of data. Create a third array of integers for a result array. Your main program will take the two arrays of integers and pass them to the function subtract(). Inside the function, subtract the first array from the second array and put the difference into the third array. Print the values of all three arrays back in the main program. Here is what I currently have. #include#include #define SIZE 10 #define SIZE 10 #define SIZE 10 int subtract(int a, int b) { return (a-b); } int main() { int *array = int[3]; array0[10] = {20,19,18,17,16,15,14,13,12,11,10}; array1[10] = {10,9,8,7,6,5,4,3,2,1,2}; array[2] = subtract(array[0], array[1]); printf("%i %i %i ", array[0], array[1], array[2]); system("PAUSE"); return 0; }Explanation / Answer
#include #define SIZE 10 void subtract(const int a[], const int b[], int c[]); void printArr(int arr[]); int main() { //int *array = int[3]; int i,j; int array0[SIZE] = {20,19,18,17,16,15,14,13,12,11}; int array1[SIZE] = {10,9,8,7,6,5,4,3,2,1,2}; int array2[SIZE]; subtract(array0, array1,array2); printf(" First Array: "); printArr(array0); printf(" Second Array: "); printArr(array1); printf(" Third Array: "); printArr(array2); getchar(); return 0; } void subtract(const int a[],const int b[], int c[]) { 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.