- #1
doktorwho
- 181
- 6
Homework Statement
A small list of business firms have their own registar number which is between 10000 and 30000. The first 4 digits represent the firm and the fifth digit is the control digit. The number is valid if the sum of all its digits are divisible by 7. Create a program which checks this.
Code:
program reg_num(input, output);
var
i, num, sum:integer;
begin
write(output, 'Enter a number:');
read(input, num);
if (num<10000) or (num>30000) then
writeln(output, 'Not Correct')
else
begin
sum:=0;
for i:=1 to 5 do
begin
sum:=sum + num mod 10;
num:=num div 10
end;
if sum mod 7=0 then
writeln(output, 'Correct')
else
writeln(output, 'Not Correct')
end;
end.
Homework Equations
3. The Attempt at a Solution [/B]
Everything is clear except for theis part:
Code:
begin
sum:=0;
for i:=1 to 5 do
begin
sum:=sum + num mod 10;
num:=num div 10
end;