Code Snippets »
C/C++ Code Snippets
C program to find sum of all digits until sum is not in single digit
This program is asked by kalyani shevale through comment on 18/12/2016.
I want one program code
input is an only integer value and output will be displayed only one digit in c
input int a=8999
Here, we are writing this code to calculate sum of all digits until sum is not in single digit in c programming language.
If number is 8999 the sum will be 8+9+9+9 = 35 = 3+5 = 8
This program is implementing by using recursion function, the function calculateDigits() is calling recursively until sum is not less than 10.
int calculateDigits(int num)
printf("Enter any positive integer number: ");
printf("Sum of digits is: %d\n",sum);
Enter any positive integer number: 8999
Sum of digits is: 8
Enter any positive integer number: 12345
Sum of digits is: 6
Most viewed pages
C Tips and Tricks
- My personal website.
Keywords (like Linux, Java, Oracle etc) used in this website are the trademarks of their respective owners/company. This website is not affiliated to any company. The tutorials are designed by includehelp Team with the help of well known books and other online resources. These Tutorials are free for all, for learning purposes only. Enjoy learning:)
Copyright © 2015 - 2016. All Rights Reserved.