Category : Pascal Source Code
Archive   : PAS-SCI.ZIP
Filename : DETERM.PAS

 
Output of file : DETERM.PAS contained in archive : PAS-SCI.ZIP
program determ; { -> 55 }
{ pascal program to calculate the determinant of a 3-by-3matrix }

type ary2 = array[1..3,1..3] of real;

var a : ary2;
n : integer;
yesno : char;
d : real;

procedure get_data(var a: ary2;
var n: integer);

{ get values for n and arrays x,y }

var i,j : integer;

begin
n:=3;
writeln;
for i:=1 to n do
begin
for j:=1 to n do
begin
write(j:3,':');
readln(a[i,j])
end { j-loop }
end; { i-loop }
writeln;
for i:=1 to n do
begin
for j:=1 to n do
write(a[i,j]:7:4,' ');
writeln
end;
writeln
end; { procedure get_data }




function deter(a: ary2): real;
{ calculate the determinant of a 3-by-3matrix }

var
sum : real;

begin
sum:=a[1,1]*(a[2,2]*a[3,3]-a[3,2]*a[2,3])
-a[1,2]*(a[2,1]*a[3,3]-a[3,1]*a[2,3])
+a[1,3]*(a[2,1]*a[3,2]-a[3,1]*a[2,2]);
deter:=sum
end;



begin { MAIN program }
ClrScr;
repeat
get_data(a,n);
d:=deter(a);
writeln('The determinant is',d);
writeln;
write('More?');
readln(yesno);
ClrScr
until (yesno<>'Y')and(yesno<>'y')
end.


  3 Responses to “Category : Pascal Source Code
Archive   : PAS-SCI.ZIP
Filename : DETERM.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/