So you are searching for the sum of the digits for any number between a given upper and lower bound?
%
and /
with integer operands, you can use n % 10
to get n
s last digit and n / 10
to drop it.
As this is obviously a homework, there will be no one presenting you a full solution (I hope).