Given a one-dimensional array of integers, write a program for calculating the number
Given a one-dimensional array of integers, write a program for calculating the number of positive and negative numbers in the array.
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);
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 + 1; // check if the next element of the array is negative, then count it
if m [i]> 0 then k: = k + 1; // check if the next element of the array is positive, then count it
end;
writeln (‘number of negative array elements =’, s); // display the answer
writeln (‘the number of positive array elements =’, k);
end.