# Given an array X (N). Find the smallest element if it is negative, replace all elements of the array with their modules.

August 27, 2021 | education

| program zz1;

const n = 10; // set the number of numbers in the array

var i, min: integer; // set variables of integer type

m: array [1..n] of integer;

begin

for i: = 1 to n do // organize a loop in which we enter n given numbers from the keyboard into the array

read (m [i]);

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

if min <0 then for i: = 1 to n do m [i]: = abs (m [i]); // check if the minimum element is negative, then replace all array elements with their modules

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.