program SumOfFourDigitNumber;
varnumber, sum, firstDigit, secondDigit, thirdDigit, fourthDigit: integer;
beginwrite('Enter a four-digit number: ');readln(number);
firstDigit := number div 1000;secondDigit := (number mod 1000) div 100;thirdDigit := (number mod 100) div 10;fourthDigit := number mod 10;
sum := firstDigit + secondDigit + thirdDigit + fourthDigit;
writeln('The sum of the four-digit number is: ', sum);end.
program SumOfFourDigitNumber;
var
number, sum, firstDigit, secondDigit, thirdDigit, fourthDigit: integer;
begin
write('Enter a four-digit number: ');
readln(number);
firstDigit := number div 1000;
secondDigit := (number mod 1000) div 100;
thirdDigit := (number mod 100) div 10;
fourthDigit := number mod 10;
sum := firstDigit + secondDigit + thirdDigit + fourthDigit;
writeln('The sum of the four-digit number is: ', sum);
end.