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

Inside main () declare a two dimensional integer array name \"One\" having three

ID: 3647631 • Letter: I

Question

Inside main () declare a two dimensional integer array name "One" having three rows and four columns. Pass this array to following functions. Input () function to input array elements. Print () function to display array elements in a row and column format. Reversed() function that will reverse the array elements by converting rows to columns and columns format as shown in an example given below and print it. (Think of switching rows and columns) Copy () function that will copy two dimensional array "One" to another two-dimensional array "Two" and then call Print () function to print both arrays One and Two. Find () function that will search for a particular element in array One. The element to be searched is input from the keyboard in a variable "WhatToFind". If the element is found in the array, then display its row and column subscript.

Explanation / Answer

please rate - thanks

#include <iostream>
using namespace std;
void Input(int[][4],int,int);
void Print(int[][4],int,int);
void Reverse(int[][4],int,int);
void Copy(int[][4],int,int);
void Find(int[][4],int,int);
int main()
{int One[3][4];
Input(One,3,4);
Print(One,3,4);
Reverse(One,3,4);
Copy(One,3,4);
Find(One,3,4);
system("pause");
return 0;
}
void Input(int One[][4],int row,int col)
{int i,j;
for(i=0;i<row;i++)
    for(j=0;j<col;j++)
      {cout<<"Enter value for row "<<i<<", column "<<j<<": ";
      cin>>One[i][j];
      }
}
void Print(int One[][4],int row,int col)
{int i,j;
cout<<"array ";
for(i=0;i<row;i++)
    {for(j=0;j<col;j++)
        cout<<One[i][j]<<" ";
      cout<<endl;
      }
}
void Reverse(int One[][4],int row,int col)
{cout<<"Array Reverse ";
int Two[4][4],i,j;
for(i=0;i<row;i++)
    for(j=0;j<col;j++)
        Two[j][i]=One[i][j];
Print(One,row,col);
Print(Two,col,row);
}

void Copy(int One[][4],int row,int col)
{int Two[3][4],i,j;
for(i=0;i<row;i++)
     for(j=0;j<col;j++)
        Two[i][j]=One[i][j];
Print(One,3,4);
Print(Two,3,4);     
}
void Find(int One[][4],int row,int col)
{int WhatToFind,i,j;
bool found=false;
cout<<"Enter value to find: ";
cin>>WhatToFind;
for(i=0;i<row;i++)
   for(j=0;j<col;j++)
      if(WhatToFind==One[i][j])
            {cout<<WhatToFind<<" is at row "<<i<<" col "<<j<<endl;
             found=true; //may occur > 1 time
             }
if(!found)
     cout<<WhatToFind <<" is not in the matrix ";
}