In the array, all positive elements should be doubled, and all negative elements
February 9, 2021 | education
| In the array, all positive elements should be doubled, and all negative elements should be replaced by 7. Display the original and transformed arrays.
Const // connect the constant;
n = 15; // constant value;
var
a: array [1..n] of integer; // cycle value;
i: integer; // variable of integer type;
begin
Randomize; // connect the randomizer;
Writeln (‘Array Elements’); // Please enter the array elements;
for i: = 1 to n do // loop using a randomizer;
begin
a [i]: = Random (61) – 30;
Write (a [i]: 4);
if a [i]> 0 then a [i]: = 2 * a [i]
else
if a [i] <0 then a [i]: = 7
end;
Writeln; // output before conversion;
Writeln (‘After conversion’); // output after conversion;
for i: = 1 to n do Write (a [i]: 4); // new cycle;
Writeln
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.