Write a program that fills the array a [1..20] with random integers in the range

Write a program that fills the array a [1..20] with random integers in the range from 1 to 30 and displays elements whose values are even and multiples of 3.

The programming language is Pascal.

The comments (denoted by //, made in italics) explain in detail what is done and how.

Let’s create all the necessary variables
var // declare variables.
massiv: array [1..20] of integer; // create an array, naming it “massiv”. integer – variable type, integer value.
a: integer; // create a variable a. The variable type is integer.

Moving on to the hardest part – creating loops
begin // operator bracket.
randomize; // turn on the random number generator.
for a: = 1 to 20 do // create a cycle. Literally: “For a variable from 1 to 20, do”.
massiv [a]: = Random (30); // assign random values ​​up to 30 to the array.
for a: = 1 to 20 do // create a cycle. Literally: “For a variable from 1 to 20, do”.
if (massiv [a] mod 2 = 0) and (massiv [a] mod 3 = 0) then // Literally: If a, dividing modulo 2, gives remainder 0, or if a modulo 3 gives in remainder 0.
write (massiv [a], ”); // display the value a that satisfies the loop. ” is used as a space.
end. // operator bracket.

Let’s start the program. It was successfully completed. In my case, the answers were as follows:

6;
6;
24;
0;
24.



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.