A four-digit number is entered from the keyboard, Find the sum of the digits, through the program in Pascal ABC.

program zz1;
var s, n, k: integer; // set variables of integer type
begin
write (‘enter a four-digit number’);
read (n); // enter a four-digit number from the keyboard
s: = 0; // set the initial value for the sum
while n> 0 do // organize a loop while there are numbers in the number
begin
k: = n mod 10; // get the last digit of a four-digit number
s: = s + k; // add it to the sum
n: = n div 10; // discard it from the number
end;
// display the answer
writeln (‘the sum of the digits of a four-digit number =’, s);
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.