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

Fill a two dimensional array with the following numbers 1 2 3 4 5 2 4 6 8 10 3 6

ID: 3814635 • Letter: F

Question

Fill a two dimensional array with the following numbers 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 Allow the computer to determine the largest value in the array Allow the user to input a value from the array and have the location output Subtract the max value from Numbers[2][3] (calculation using the location must exist in the program) Example The largest number in the array is: 20 Input a number: 2 Your number is at Numbers[0][1] The difference between the max value and Numbers[2][3] is: 12

Explanation / Answer

// location

int input2;

cin >> input2;

for (int row = 0; row < FOUR; row++)

  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20  21  22  23    
  #include <iostream>  #include <iomanip>    using namespace std;    const int FOUR= 4;      int main()  {      int gameboard [FOUR][FOUR];            for (int row = 0; row < FOUR; row++)      {          for (int col=0; col < FOUR; col++)          {              int input ;              cin>>input;              gameboard[row][col] = input;              }              }  int max = gameboard[0][0];  // calculate maximum      
  for (int row = 0; row < FOUR; row++) { for (int col=0; col < FOUR; col++) {
if( max < gameboard[row][col]) max = gameboard[row][col] ; } }

// location

int input2;

cin >> input2;

for (int row = 0; row < FOUR; row++)

      {          for (int col=0; col < FOUR; col++)          {              if(input2 == gameboard[row][col])              {                 cout<<"element is locted at "<<row<<col;              }                                          }              }  
int result = max - gameboard[2];
cout<<result; return 0; }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote