Find the arithmetic mean of positive and negative elements of an array, write a program in pascal.

program zz1;

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

var i, s1, k1, s2, k2: 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 begin s1: = s1 + m [i]; k1: = k1 + 1; end; // check if the next element of the array is negative, then count the sum and quantity

if m [i]> 0 then begin s2: = s2 + m [i]; k2: = k2 + 1; end; // check if the next element of the array is positive, then count the sum and quantity

end;

writeln (‘arithmetic means of positive array elements =’, s1 / k1); // display the answer

writeln (‘arithmetic means of negative array elements =’, s2 / k2);

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.