Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

matrix c++

void matrixInput(int n, int m, int **arr)
{
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> arr[i][j];
    }
  }
}

void matrixDisplay(int n, int m, int **arr)
{

  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
}

void matrix()
{
  int n, m;
  cout << "Enter matrix row and column: ";
  cin >> n >> m;

  int **arr;
  arr = new int *[m];
  for (int i = 0; i < m; i++)
    arr[i] = new int[m];

  matrixInput(n, m, arr);
  cout << "
Displaying matrix: 
";
  matrixDisplay(n, m, arr);
}
 
PREVIOUS NEXT
Tagged: #matrix
ADD COMMENT
Topic
Name
7+5 =