Given a natural number n, real numbers a1, …, ann. In the sequence a1, .
Given a natural number n, real numbers a1, …, ann. In the sequence a1, …, andn increase all negative terms by 0.5 and replace all nonnegative terms by 0.1.
program zz1;
const n = 5; // set the number of elements in the array
var i: integer; // set variables of integer type
a: array [1..n] of real;
begin
for i: = 1 to n do // get n random numbers and write them into an array
a [i]: = random (51) -25 + random;
for i: = 1 to n do // display the original array on the screen as a string in the format of eight digits for a number and two decimal places
write (a [i]: 8: 2);
writeln; // go to a new line to display the response
for i: = 1 to n do
if a [i] <0 then a [i]: = a [i] + 0.5 else a [i]: = 0.1;
for i: = 1 to n do // display the resulting array on the screen as a string in the format of eight digits for a number and two decimal places
write (a [i]: 8: 2);
end.