Given an array of real numbers, in which it is necessary to display the numbers of negative elements

Given an array of real numbers, in which it is necessary to display the numbers of negative elements and find the sum of positive ones.

program zz1;
const n = 5; // set the number of numbers in the array
var i: integer; // set a variable of integer type
s: real;
x: array [1..n] of real;
begin
for i: = 1 to n do // organize a loop in which we enter n given numbers from the keyboard into the array
read (x [i]);
write (‘numbers of negative elements:’);
for i: = 1 to n do // organize a loop in which we check if an array element is negative, then display its number on the screen
if x [i] <0 then write (i, ”);
for i: = 1 to n do // organize a loop in which we check if the array element is positive, then add it to the sum
if x [i]> 0 then s: = s + x [i];
writeln;
write (‘sum of positive elements =’, s: 5: 2); // display the resulting sum in the format of five digits for a number and two decimal places
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.