An array of 50 numbers is given. Fill it with random numbers. Display first all positive elements
An array of 50 numbers is given. Fill it with random numbers. Display first all positive elements of it, and then all negative ones.
program zz1;
const n = 50; // set the number of elements in the array
var i, k, s: 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 (101) -50;
for i: = 1 to n do // display the resulting array on the screen
write (m [i], ”);
writeln; // go to a new line to display the response
writeln (‘positive array elements:’);
for i: = 1 to n do
if m [i]> 0 then write (m [i], ”);
writeln; // go to a new line to display the response
writeln (‘negative array elements:’);
for i: = 1 to n do
if m [i] <0 then write (m [i], ”);
end.