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.
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.