example:
13 ---> 1+3=4
135 ---> 1+3+5=8
1.382 OR 0.000 or 2831
int sum_digits (int num) { int sum; sum =0; while (num) { sum += num % 10; num /= 10; } return sum; } Example usage: int main (void) { int i; printf ("Input a 6-digit number: "); scanf ("%6d", &i); printf ("The sum of the digits in %d is: %d\n", i, sum_digits (i)); return 0; }
# includevoid main(){int no,rem=0,sum=0,n; /*declaration*/printf("Enter 2 digit number:");scanf("%d",&no);for(n=1;n
5
Add the last digit plus the sum of all the previous digits. The base case is that if your integer only has a single digit, just return the value of this digit. You can extract the last digit by taking the remainder of a division by 10 (number % 10), and the remaining digits by doing an integer division by 10.
The sum is the total of numbers added together.
What is the sum of greatest 3-digit 4-digit 5digit
sum
what is the least possible sum of two 4-digit numbers?what is the least possible sum of two 4-digit numbers?
None. The sum of one digit can't be twice the size of the digit.
The final sum is 9
9
i am a two digit # my tens digit# is 3 times my ones digit #and the sum of my digit is 12 what am i
The sum of the individual digit is itself
The units digit of a two digit number exceeds twice the tens digit by 1. Find the number if the sum of its digits is 10.
199999.
120