Professional Documents
Culture Documents
second matrix. This program displays the error until the number of columns of first matrix is equal to the
number of rows of second matrix.
#include <iostream>
int main()
cout << "Enter rows and columns for first matrix: ";
cout << "Enter rows and columns for second matrix: ";
while (c1!=r2)
cout << "Error! column of first matrix not equal to row of second.";
cout << "Enter rows and columns for first matrix: ";
cout << "Enter rows and columns for second matrix: ";
cout << endl << "Enter elements of matrix 1:" << endl;
for(i = 0; i < r1; ++i)
cout << "Enter element a" << i + 1 << j + 1 << " : ";
cout << endl << "Enter elements of matrix 2:" << endl;
cout << "Enter element b" << i + 1 << j + 1 << " : ";
mult[i][j]=0;
{
mult[i][j] += a[i][k] * b[k][j];
if(j == c2-1)
return 0;