In the array M [12,12], the values of the elements are in the interval [-10,50]

In the array M [12,12], the values of the elements are in the interval [-10,50], calculate the sum of the negative elements located on the main diagonal.

var
M:array[1..12,1..12] of integer;
sum:integer;

begin
for i:integer:=1 to 12 do
begin
for j:integer:=1 to 12 do
begin
M[i,j]:=random(60)-10;
write(M[i,j]:5);
if (i = j) and (M[i,j]<0) then
sum:=sum+M[i,j];
end;
writeln();
end;
writeln(‘Сумма: ‘, sum);
end.



One of the components of a person's success in our time is receiving modern high-quality education, mastering the knowledge, skills and abilities necessary for life in society. A person today needs to study almost all his life, mastering everything new and new, acquiring the necessary professional qualities.