Check out example codes for "sum the digits in c#". It will help you in understanding the concepts better.

Code Example 1

sum = 0;
while (n != 0) {
    sum += n % 10;
    n /= 10;
}

Learn ReactJs, React Native from akashmittal.com