Thursday, 9 February 2012

QBASIC Program To Solve For The Determinant Of An Order 3 Matrix Using Sarrus Method.

version 1.0.1
CLS
'PROGRAM TO SOLVE FOR THE DETERMINANT OF AN ORDER 3 MATRIX USING SARRUS METHOD"
'THIS VERSION USES THE READ/DATA STATEMENT
DIM M(3, 3)
'INPUT THE ELEMENTS IN THE ORDER OF TOP TO BOTTOM AND LEFT TO RIGHT
DATA 2,3,2,4,1,3,2,4,3

FOR I = 1 TO 3
FOR J = 1 TO 3
READ M(I, J)
NEXT J
NEXT I

D = M(1, 1) * M(2, 2) * M(3, 3) + M(1, 2) * M(2, 3) * M(3, 1) + M(1,
3) * M(2, 1) * M(3, 2) - M(3, 1) * M(2, 2) * M(1, 3) - M(3, 2) * M(2,
3) * M(1, 1) - M(3, 3) * M(2, 1) * M(1, 2)

PRINT "THE DETERMINANT IS"; D
END


version 1.0.2
CLS
'PROGRAM TO SOLVE FOR THE DETERMINANT OF AN ORDER 3 MATRIX USING SARRUS METHOD"
'THIS VERSION USES THE INPUT STATEMENT
DIM M(3, 3)

FOR I = 1 TO 3
FOR J = 1 TO 3
PRINT I; ","; J
INPUT M(I, J)
NEXT J
NEXT I

D = M(1, 1) * M(2, 2) * M(3, 3) + M(1, 2) * M(2, 3) * M(3, 1) + M(1,
3) * M(2, 1) * M(3, 2) - M(3, 1) * M(2, 2) * M(1, 3) - M(3, 2) * M(2,
3) * M(1, 1) - M(3, 3) * M(2, 1) * M(1, 2)

PRINT "THE DETERMINANT IS"; D
END

No comments:

Post a Comment

Please comment if there's anything you feel can be added or if you have any questions. Thanks.