Целая программа на паскале:
const
a: array [1..4, 1..4] of integer =
((1,2,3,4),(5,6,7,8),(9,10,11,12),(13,14,15,16));
var
i, j: integer;
begin
writeln('matrix:');
for i := 1 to 4 do begin
for j := 1 to 4 do write(a[i,j]:4);
writeln;
end;
writeln;
writeln('main diagonal sum: ', a[1,1] + a[2,2] + a[3,3] + a[4,4]);
end.