Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
444 B
2
Indexable
Never
program SumOfNegativeElements;

var
  arr: array[1..10] of integer;
  i, sum: integer;

begin
  sum := 0;
  Randomize;
  
  for i := 1 to 10 do
  begin
    arr[i] := Random(21) - 10;
    if arr[i] < 0 then
      sum := sum + arr[i];
  end;
  
  writeln('Сгенерированный массив:');
  for i := 1 to 10 do
    write(arr[i], ' ');
  
  writeln;
  writeln('Сумма отрицательных элементов: ', sum);
end.
Leave a Comment