An array is given, specified by the generator of random numbers in the interval [-60; 140].
An array is given, specified by the generator of random numbers in the interval [-60; 140]. Determine the minimum and maximum element of the array.
program zz1;
const n = 14; // set the number of elements in the array
var i, max1, min: integer; // set variables of integer type
m: array [1..n] of integer;
begin
for i: = 1 to n do // write numbers in the array at random
m [i]: = random (201) -60;
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
max1: = 0;
for i: = 1 to n do // find the maximum element
if m [i]> max1 then max1: = m [i];
writeln (‘max element =’, max1); // display the answer
min: = 1,000,000; // set the initial value for the minimum element
for i: = 1 to n do // organize a loop in which we iterate over all the numbers in the array
if m [i] <min then min: = m [i]; // check if the number from the array is less than the minimum, then write it to the minimum
write (‘minimum element =’, min); // display the answer
end.