An integer array of 30 elements is given. The array elements can take values from 0 to 1000. Describe in Russian or one of the programming languages an algorithm that allows you to calculate and display the arithmetic mean of array elements that have an odd value. It is guaranteed that at least one element in the original array has an odd value.
const n = 30; // set the number of elements in the array
var i, k, s: integer; // set variables of integer type
m: array [1..n] of integer;
for i: = 1 to n do // write numbers in the array at random
m [i]: = random (1001);
for i: = 1 to n do // display the array on the screen
write (m [i], ”);
writeln; // go to a new line to display the response
for i: = 1 to n do
if m [i] mod 2 = 1 then begin s: = s + m [i]; k: = k + 1; end;
write (‘arithmetic mean of odd elements =’, s / k);
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.