DIM a(4, 4)
RANDOMIZE TIMER
p = 1
FOR i = 1 TO 4
FOR j = 1 TO 4
a(i, j) = INT(RND * 10) - 5
IF a(i, j) <> 0 THEN p = p * a(i, j)
IF i = j THEN s = s + a(i, j)
NEXT
NEXT
PRINT "massiv"
FOR i = 1 TO 4
FOR j = 1 TO 4
PRINT a(i, j);
NEXT
PRINT
NEXT
PRINT "proizvedenie="; p
PRINT "srednee="; s / 4
Тестирование выполнено в программе QB64 ( Скачать )