program SumOfDigitsAboveK;
varN, k, number, sum: integer;
beginwrite('Enter a four-digit number N: ');readln(N);
write('Enter an integer k: ');readln(k);
sum := 0;number := N;
while number > 0 dobeginif (number mod 10) > k thensum := sum + (number mod 10);
end;
writeln('The sum of digits in ', N, ' that are greater than ', k, ' is ', sum);end.
program SumOfDigitsAboveK;
var
N, k, number, sum: integer;
begin
write('Enter a four-digit number N: ');
readln(N);
write('Enter an integer k: ');
readln(k);
sum := 0;
number := N;
while number > 0 do
number := number div 10;begin
if (number mod 10) > k then
sum := sum + (number mod 10);
end;
writeln('The sum of digits in ', N, ' that are greater than ', k, ' is ', sum);
end.