In an array of 10 elements, filled with random numbers from the range
September 6, 2021 | education
| In an array of 10 elements, filled with random numbers from the range from –15 to 15, find the largest and smallest elements of the array at the same time.
program min_max;
var A: array [1..10] of integer;
max, min: integer;
begin
randomize;
for i: integer: = 1 to 10 do // fill the array
begin
A [i]: = random (31) – 15;
write (a [i]: 5)
end;
max: = A [1];
min: = A [1];
for i: integer: = 2 to 10 do // find the minimum and maximum elements
begin
if a [i]> max then max: = a [i];
if a [i] <min then min: = a [i];
end;
// display the minimum and maximum values of the array elements
writeln ();
writeln (‘min =’, min: 3, ‘max =’, max: 3)
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.