Rem  Program matadd.bas
Rem  To Add 2 matrices. The Maximum order of each matrix can be 40
Dim a(40,40), b(40,40), c(40,40)
MAXSIZE = 40
Rem Get dimensions of matrices
Do
   Input "Enter No. of rows of Matrices"; Nrow
   If Nrow > 0 and Nrow <= MAXSIZE and Nrow = Int(Nrow) Then Exit Do
   print "Invalid Size"
Loop
Do
   Input "Enter No. of columns of Matrices"; Ncol
   If Ncol > 0 and Ncol <= MAXSIZE and Ncol = Int(Ncol) Then Exit Do
   print "Invalid Size"
Loop
REM GET THE MATRIX-A
PRINT "Enter the Matrix-1(One Element per line)"
FOR I = 1 TO Nrow
  PRINT USING "**********ROW = ##**********"; I
  FOR J = 1 TO NCol
    INPUT A(I,J)
  NEXT J
  PRINT
NEXT I

REM GET THE MATRIX-B
PRINT "Enter the Matrix-2(One Element per line)"
FOR I = 1 TO Nrow
  PRINT USING "**********ROW = ##**********"; I
  FOR J = 1 TO NCol
    INPUT B(I,J)
  NEXT J
  PRINT
NEXT I

Rem ADD THE Matrices
For i = 1 to Nrow
   For j = 1 to Ncol
      c(i,j) = a(i,j) + b(i,j)
   Next j
Next i

Rem Print the Result
print "*** SUM OF MATRICES ***"
for i = 1 to Nrow
   PRINT USING "***********ROW =### ********"; i
   for j = 1 to Ncol
     PRINT USING "#####.##"; C(I,J)
   Next j
Next i
End

