program DivisibilityBy3;
varnum, sum, digit: integer;
beginwriteln('Enter a four-digit number: ');readln(num);
sum := 0;
while num <> 0 dobegindigit := num mod 10;sum := sum + digit;num := num div 10;end;
if sum mod 3 = 0 thenwriteln('The four-digit number is divisible by 3.')elsewriteln('The four-digit number is not divisible by 3.');end.
program DivisibilityBy3;
var
num, sum, digit: integer;
begin
writeln('Enter a four-digit number: ');
readln(num);
sum := 0;
while num <> 0 do
begin
digit := num mod 10;
sum := sum + digit;
num := num div 10;
end;
if sum mod 3 = 0 then
writeln('The four-digit number is divisible by 3.')
else
writeln('The four-digit number is not divisible by 3.');
end.