You are given a one-dimensional real array B (N). Find the sum of the positive elements of an array.
September 14, 2021 | education
| program zz1;
const n = 5; // set the number of elements in the array
var i: integer; // set variables of integer type
b: array [1..n] of real;
s: real;
begin
for i: = 1 to n do // get n random numbers and write them into an array
b [i]: = random (51) -25 + random;
for i: = 1 to n do // display the resulting array on the screen
write (b [i]: 8: 2);
writeln; // go to a new line to display the response
for i: = 1 to n do
if b [i]> 0 then s: = s + b [i]; // get the sum
writeln (‘the sum of positive elements =’, s: 5: 2); // display the answer
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.