Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a 3 by 4 two dimensional array and fill it with the following numbers: 11

ID: 3674062 • Letter: C

Question

Create a 3 by 4 two dimensional array and fill it with the following numbers: 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,22 Create a second 3 by 4 two dimensional array and will it with the following numbers: 1,2,4, 6, 8, 10, 12, 14, 16, 18, 20, 22 Create a third 3 by 4 array and use for loops to generate and hold the values of the second array subtracted from the first array. You must do this with an algorithm, it cannot be hard coded in this third array. Output all three two dimensional arrays to the screen in a manner that looks like three separate tables or matrixes. The final date/time to submit this assignment is Friday, March 4th at midnight.

Explanation / Answer

#include<iostream>

using namespace std;


int main(){
   // first array
   int first[3][4] = {{11,12,13,14},{15,16,17,18},{19,20,21,22}};
   //second array
   int second[3][4] = {{1,2,4,6},{8,10,12,14},{16,18,20,22}};
  
   int finalArr[3][4];
  
   for(int i=0; i<3; i++){
       for(int j=0; j<4; j++)
           finalArr[i][j] = first[i][j] - second[i][j];
       }
  
   //printing final array
   for(int i=0; i<3; i++){
       for(int j=0; j<4; j++){
           cout<<finalArr[i][j]<<" ";
       }
       cout<<endl;
       }
   cout<<endl;
  
   return 0;
   }

/*

Output:

10 10 9 8
7 6 5 4
3 2 1 0

*/