# Write a pascal program: find the sum of all numbers from the keyboard that are multiples of a given number a.

March 30, 2021 | education

| program zz1;

var a, b, n, i, m: integer; // set variables of integer type

begin

write (‘enter how many numbers we will enter’); // enter a number from the keyboard

read (n);

write (‘enter the given number a’); // enter a number from the keyboard

read (a);

for i: = 1 to n do

begin

read (b); // enter the number

if b mod a = 0 then m: = m + b; // check if the number is divisible by the given one without a remainder, then add it to the sum

end;

write (‘the sum of all numbers from the keyboard, multiples of a given number a =’, m); // display the answer

end.