Write a program that fills the array a [1..10] with random integers in the range from 1 to 10
Write a program that fills the array a [1..10] with random integers in the range from 1 to 10, then transforms it, increasing all odd-valued elements three times, and replacing even-valued elements with 0.
The solution of the problem:
Cohn is written in PascalABC.NET program.
var a: array [1..10] of integer;
i: integer;
begin
randomize;
write (‘Initial array:’);
for i: = 1 to 10 do
begin
a [i]: = random (1, 10); // The array is filled with arbitrary integers in the range from 1 to 10.
write (a [i], ”); // This procedure displays the array numbers on the screen, separated by a space in a line.
end;
writeln;
write (‘Transformed array:’);
for i: = 1 to 10 do
begin
if odd (a [i]) = true then begin
a [i]: = a [i] * 3;
write (a [i], ”);
end
else begin
a [i]: = 0;
write (a [i], ”);
end;
end;
end.