Given a one-dimensional array of 10 integers, find the sum of negative and positive numbers separately. Pascal language

program zz1;

const n = 10; // set the number of numbers in the array

var i, s, k: integer; // set variables of integer type

m: array [1..n] of integer;

begin

for i: = 1 to n do // get n random numbers and write them into an array

m [i]: = random (51) -25;

for i: = 1 to n do // organize a loop in which we iterate over all the numbers in the array

begin

if m [i] <0 then s: = s + m [i]; // check if the next element of the array is negative, then add it to the sum

if m [i]> 0 then k: = k + m [i]; // check if the next element of the array is positive, then add it to the sum

end;

writeln (‘sum of negative array elements =’, s); // display the answer

writeln (‘the sum of positive array elements =’, k);

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.