# Find in the array in (10) the sum of elements with even numbers.

July 26, 2021 | education

| Program summ;

var

B: array [1..100] of integer;

n, i, sum: integer;

begin

writeln (‘Enter the number of elements in the array’);

readln (n);

for i: = 1 to n do B [i]: = random (100);

for i: = 1 to n do

if i mod 2 = 0 then sum: = sum + B [i];

writeln (‘The sum of elements with even indices is:’, sum);

readln;

end.

In the condition, we use the function of allocating the remainder of the division mod. If the remainder of division by 2 is 0, then the number is even.

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.