Fill a one-dimensional array consisting of N elements with numbers randomly selected from the range

Fill a one-dimensional array consisting of N elements with numbers randomly selected from the range [a, b]. The value of N is described as a constant, the values of a and b are specified from the keyboard. Display the elements of the array to the screen in a string. Calculate the sum of the array elements and display it on the screen.

program zz1;
const n = 50; // set the number of elements in the array
var i, s, a, b: integer; // set variables of integer type
m: array [1..n] of integer;
begin
write (‘enter the given number a’);
read (a);
write (‘enter the given number b’);
read (b);
for i: = 1 to n do // get n random numbers and write them into an array
m [i]: = random (b) + a;
for i: = 1 to n do // display the resulting array on the screen
write (m [i], ”);
writeln; // go to a new line to display the response
for i: = 1 to n do
s: = s + m [i];
writeln (‘sum of elements =’, s); // 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.