Write a program that fills an array with random integers, enters an integer N from the keyboard

Write a program that fills an array with random integers, enters an integer N from the keyboard, and copies into a new array all numbers from the original array for which the sum of the values of all digits is N.

const nmax = 100;
function summa (a: integer): integer;
var b, s: integer;
begin
b: = abs (a);
s: = 0;
while b> 0 do
begin
s: = s + b mod 10;
b: = b div 10;
end;
result: = s;
end;
var a: array [1..nmax] of integer;
m, n, i, k: integer;
begin
randomize;
repeat
write (‘Enter the size of the array from 2 to’, nmax, ‘m =’);
readln (m);
until m in [2..nmax];
writeln (‘Array’);
for i: = 1 to m do
begin
a [i]: = – 99 + random (1099);
write (a [i]: 4);
end;
writeln;
repeat
write (‘Enter the required sum of digits n> 0 n =’);
readln (n);
until n> 0;
k: = 0;
for i: = 1 to m do
if summa (a [i]) = n then
begin
write (a [i]: 4);
k: = 1;
end;
if k = 0 then write (‘There are no numbers with such a sum of digits’);
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.