@@ -9,22 +9,22 @@ public static void main(String args[]) {
99 Scanner in = new Scanner (System .in );
1010
1111 System .out .print ("Enter Number of Rows and Columns of First Matrix : " );
12- m = in .nextInt ();
13- n = in .nextInt ();
12+ m = in .nextInt (); // enter no. of rows of first matrix
13+ n = in .nextInt (); // enter no. of vplumns of first matrix
1414
1515 int first [][] = new int [m ][n ];
1616
1717 System .out .print ("Enter First Matrix Elements : " );
1818
1919 for (c = 0 ; c < m ; c ++) {
2020 for (d = 0 ; d < n ; d ++) {
21- first [c ][d ] = in .nextInt ();
21+ first [c ][d ] = in .nextInt (); // here we have to enter first matrix's element
2222 }
2323 }
2424
2525 System .out .print ("Enter Number of Rows and Columns of Second Matrix : " );
26- p = in .nextInt ();
27- q = in .nextInt ();
26+ p = in .nextInt (); // enter no. of vplumns of second matrix
27+ q = in .nextInt (); // enter no. of vplumns of second matrix
2828
2929 if (n != p ) {
3030 System .out .print ("Matrix of the entered order can't be Multiplied..!!" );
@@ -36,7 +36,7 @@ public static void main(String args[]) {
3636
3737 for (c = 0 ; c < p ; c ++) {
3838 for (d = 0 ; d < q ; d ++) {
39- second [c ][d ] = in .nextInt ();
39+ second [c ][d ] = in .nextInt (); // here we have to enter second matrix's element
4040 }
4141 }
4242
@@ -48,7 +48,7 @@ public static void main(String args[]) {
4848 sum = sum + first [c ][k ] * second [k ][d ];
4949 }
5050
51- multiply [c ][d ] = sum ;
51+ multiply [c ][d ] = sum ; // here sum is the element of multiply matrix and one by 1 element will be inserted
5252 sum = 0 ;
5353 }
5454 }
@@ -58,7 +58,7 @@ public static void main(String args[]) {
5858
5959 for (c = 0 ; c < m ; c ++) {
6060 for (d = 0 ; d < q ; d ++) {
61- System .out .print (multiply [c ][d ] + "\t " );
61+ System .out .print (multiply [c ][d ] + "\t " ); // multiply matrix output
6262 }
6363 System .out .print ("\n " );
6464 }
0 commit comments