If I have a (long int x) that I want to get the sum of its digits, I know I should use modulus & devision, declare a temp variable as well as one for sum. But I am really confused about the exact equations, I only know how to get the first digit (units) by using:
and I think that I will use loops as well, do I have to?Code:temp = x % 10; sum += temp;
and what are the equations/code used?
Thanks,
Amy