3x3 matrix multiplication in c 2b 2b

Solutions on MaxInterview for 3x3 matrix multiplication in c 2b 2b by the best coders in the world

showing results for - "3x3 matrix multiplication in c 2b 2b"
Matilda
12 Mar 2016
1#include <iostream>
2using namespace std;
3
4int main()
5{
6    int a[10][10], b[10][10], mult[10][10], r1, c1, r2, c2, i, j, k;
7
8    cout << "Enter rows and columns for first matrix: ";
9    cin >> r1 >> c1;
10    cout << "Enter rows and columns for second matrix: ";
11    cin >> r2 >> c2;
12
13    // If column of first matrix in not equal to row of second matrix,
14    // ask the user to enter the size of matrix again.
15    while (c1!=r2)
16    {
17        cout << "Error! column of first matrix not equal to row of second.";
18
19        cout << "Enter rows and columns for first matrix: ";
20        cin >> r1 >> c1;
21
22        cout << "Enter rows and columns for second matrix: ";
23        cin >> r2 >> c2;
24    }
25
26    // Storing elements of first matrix.
27    cout << endl << "Enter elements of matrix 1:" << endl;
28    for(i = 0; i < r1; ++i)
29        for(j = 0; j < c1; ++j)
30        {
31            cout << "Enter element a" << i + 1 << j + 1 << " : ";
32            cin >> a[i][j];
33        }
34
35    // Storing elements of second matrix.
36    cout << endl << "Enter elements of matrix 2:" << endl;
37    for(i = 0; i < r2; ++i)
38        for(j = 0; j < c2; ++j)
39        {
40            cout << "Enter element b" << i + 1 << j + 1 << " : ";
41            cin >> b[i][j];
42        }
43
44    // Initializing elements of matrix mult to 0.
45    for(i = 0; i < r1; ++i)
46        for(j = 0; j < c2; ++j)
47        {
48            mult[i][j]=0;
49        }
50
51    // Multiplying matrix a and b and storing in array mult.
52    for(i = 0; i < r1; ++i)
53        for(j = 0; j < c2; ++j)
54            for(k = 0; k < c1; ++k)
55            {
56                mult[i][j] += a[i][k] * b[k][j];
57            }
58
59    // Displaying the multiplication of two matrix.
60    cout << endl << "Output Matrix: " << endl;
61    for(i = 0; i < r1; ++i)
62    for(j = 0; j < c2; ++j)
63    {
64        cout << " " << mult[i][j];
65        if(j == c2-1)
66            cout << endl;
67    }
68
69    return 0;
70}
71
Louisa
19 Apr 2018
13 3 3
23 3 3
queries leading to this page
matrix multiplication program in c 2b 2b using class and object taking input from usermultiply matrices where n is entered by user c 2b 2bwrite a complete c 2b 2b program to multiply two 2d matrices program should have code to check for multiplication rule c 2b 2b multiplication matrixc 2b 2b code for 2d array multiplicationmultiply two square matrices in c 2b 2bwrite a program to get a 5x5 matrices from user and get its vertex elements in c 2b 2bmatrix multipliactiom c 2b 2bc 2b 2b program for multiplication of two 2d matricesmatrix in cppmultiplying two matrix in cppmatrix multiplication using multidimensional array in c 2b 2bmatrix multiplication in c 2b 2b using 2d arraymultiplication of matrices in c 2b 2b using 2d arraysmultiplication of matrices in c 2b 2bcpp matrix multiplicationmultiplication of matrix in c 2b 2b using classprint 4x2 matrix in c 2b 2bmultiplication of matrices c 2b 2bmultiplication matrices c 2b 2bunderstand matrix multiplication using c 2b 2bmultiply matrix cppmatrix multiplication in cppmatrix multiplication coding c 2b 2bmatrix multiplication c 2b 2bc 2b 2b matrix multiplicationmatrix multiplication of 2 2a2 matrix in c 2b 2b using constructorc 2b 2b matrix multiplication functionmultiplication of two matrix in c 2b 2bwrite a c 2b 2b program to implement multiplication of 2d arrayscalculate matrix multiplication of 2x2 in cppmatrix multiplying c 2b 2bmatrix multiplication code in c 2b 2bmultiplication of matrix in c 2b 2bproduct of 2 matrices in c 2b 2bmultiplication of 2 2a2 matrix in c 2b 2bmatrix multiplications in c 2b 2bc 2b 2b multiply matrix2d array multiplication c 2b 2bc 2b 2b program to element wise multiply two matrix using multi dimensional arraysmatrix multiplication in c 2b 2bmatmult will run by being given the dimensions of the two arrays to multiply together these 4 values will be read as command line arguments in c 2b 2bc 2b 2b multiply of matrixmatrix multiplication of 2 2a2 matrix in c 2b 2b multiplying matricies c 2b 2bmultiply 2d vector matrices c 2b 2bc 2b 2b matrix multiplcationnp multiply in cpp codew a p in c 2b 2b to overload 2a operator which multiply two matrix objects w a p in c 2b 2b to calculate a intersection b where a and b are both arrayc 2b 2b code for matrix multiplicationmultiplication of matrix c 2b 2bcode for matrix multiplication in cpphow to perform matrix multiplication in c 2b 2bwrite a c 2b 2b program to multiply two 3 2a3 matrix using multidimensional arrayswrite a program in c to scan two matrices 28of appropriate order 29 pass these to a function function should multiply these two matrices and return the result to the main function display the result in main function multidimensional arrays c 2b 2bmultiplicationc plus plus program to multiply two matridxmatrix multiplication code c 2b 2bmultiplying matrices c 2b 2busual multiplication matrix 3 x 3 c 2b 2bmultiplying two rows of matric in cppmultiplication of matrices cpparray multiplication c 2b 2bc 2b 2b std matrix multiplicationmatrix multiplication and division in c 2b 2b3x3 matrix multiplication in c 2b 2bmatrix multiplication algo in c 2b 2bc 2b 2b program to multiply two matrix using multi dimensional arrays and pointermultiplication of matrices c 2b 2b codeprogram to multiply two matrices without using functions matrix multiplication in c 2bc 2b 2b function for matrix multiplicationwrite a program in c to scan two matrices 28of appropriate order 29 pass these to a function function should multiply these two matricesmatrix mult cppprogram for matrix multiplication c 2b 2bcpp multiply 2 different sized matrixprogram for implementing multiplication of two matrices in cpparray multiplication in cppwrite c 2fc 2b 2b program for storing matrix write functions for d 29 add 2c subtract and multiply two matrices with exception handlingmatrix multiplication cppcalculate matrixmultiplication of 2x2 in cppc 2b 2b comute matrxi multiplication write a program 2c which take input of two matrix from user on console 28m1 of size 2x3 29 and m2 of 28size 3x2 29c 2b 2b matrix code3x3 matrix multiplication in c 2b 2b