Sum of digits in c or c++ without pointers

SO, the main logic behind this is=:
b = a%10; // we took the remainder after dividing by 10 thats the last digit
sum = sum+ (b*c); // adding last digit to sum
a = a/10; //to remove last digit from a
c= c/10; //to remove last digit from a
and in last we will return sum.

Leave a comment