answersLogoWhite

0


Best Answer

int digsum (int n)

{

if (n<10) return n;

else return (n%10) + digsum (n/10);

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Sum of digits of number using function using c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

When using the SUBTOTAL function which is the function number for the SUM function?

4


What is the sum of all possible 2 digit number using the digits 3 and 4?

The sum is 154.


The sum of the digits of the number is 6?

the sum of my digits is 6? answer=60


How do you find the sum of digits of each number?

Add the digits together. The sum of the digits of 23 is 5.


There is a number that is 5 times the sum of its digits What is this number?

The number is 45. The sum of its digits i.e. 4+5=9 Five times the sum of its digits i.e. 5 times 9 which is 45


I ned a program to print sum of digits without using while loop?

In python 3 I would write the following (assuming the digits are input by a user): #!/usr/bin/python a = input("Type a number: ") sum = 0 for i in a: #the for next loop performs the function of a while loop with less lines of code. #(My formating keeps getting deleted when I publish this answer. There should always be a tab- strictly speaking four spaces before this line) sum = sum + int(i) sum = str(sum) print("Your number was", a + ". The sum of its digits is" , sum + ".") As you can see, the for next loop iterates through each value in the string "a", and sets its value to "i". For each iteration, the current value of i is added to the variable "sum" until the end of the number is reached. The program then prints the original number, and the sum of its digits.


A number that is equal to the sum of the digits of its cube?

8 is the same as the sum of the digits of its cube, 512.


What is the sum of the digits of the number 11?

1 + 1 = 2 The sum of the digits is therefore 2.


What does the sum of your digits?

The sum of your digits is the total number arrived at after adding two or more numbers.


Express the sum of 1111 km and 222 km using the correct number of significant digits?

The sum is: 1333 km


What does find the sum of the digits of each number above mean?

Add the digits together. The sum of the digits of 23 is 5.


There is a number that is 6 times the sum of its digits What is this number?

The number is 54. The sum of its digits is 5 + 4 = 9. 54/9 = 6.