Create an array of n random numbers and print the odd numbers.

Program jht;
var
A: array [1..100] of integer;
i, n: integer;
begin
Writeln (‘Enter the number of elements in the array’);
readln (n);
for i: = 1 to n do A [i]: = random (1000);
write (‘Original array:’);
for i: = 1 to n do writeln (A [i], ”);
write (‘Odd array elements:’);
for i: = 1 to n do if A [i] mod 2 = 1 then write (A [i]);
readln;
end.

To determine whether a number is odd, we use the Pascal language function a mod b – the remainder of dividing the number a by the number b. If the next element, when divided by 2, gives 1 by this function, then it is odd.



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.