Write a program in the Pascal program: Output first positive numbers from the segment [a; b], and then negative
Write a program in the Pascal program: Output first positive numbers from the segment [a; b], and then negative numbers from the segment [a; b] and the number of positive and negative numbers from the segment [a; b]
program zz1;
var a, b, r, i: integer; // set variables of integer type
begin
write (‘enter the first number’); // enter the first number from the keyboard
read (a);
write (‘enter the second number’); // enter the second number from the keyboard
read (b);
for i: = a to b do
begin
if i> 0 then write (”, i); // display the first answer
r: = r + 1;
end;
writeln;
writeln (‘number of positive =’, r); // print the second answer
r: = 0;
for i: = a to b do
begin
if i <0 then write (”, i); // print the third answer
r: = r + 1;
end;
writeln;
writeln (‘number of negative =’, r); // print the fourth answer
end.