Dan massia A, consisting of 12 numbers, fill the array with random numbers in the range from 0 to 100.

Dan massia A, consisting of 12 numbers, fill the array with random numbers in the range from 0 to 100. It is required to calculate the arithmetic mean of the array elements. print the array and the arithmetic mean to the screen.

var a: array [1..12] of single; S: single; M: single; i: integer; k: integer; begin randomize; for i: = 1 to 12 do a [i]: = random * 100; S: = 0; k: = 0; for i: = 1 to 12 do begin S: = S + a [i]; k: = k + 1; end; M: = S / k; for i: = 1 to 12 do begin write (a [i], ‘,’); end; writeln; writeln (‘Average =’, M); end. Explanation. Array “a []” and variables “S” and “M” of the real type “single”. Depending on the compiler, this can be changed to “real”. The call to randomize ensures that the random function produces a random number. The “random” function without parameters returns a random real number from “0” to “1”. Multiplying it by “100”, we get a random number from 0 to 100. The “S” variable accumulates the sum of the array elements, and the “k” variable contains their number. The variable was introduced for educational purposes, and in this program “k” is always equal to “12”, in principle, you can refuse it. The arithmetic mean is stored in the “M” variable.



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.