C program to find sum of all digits
To find sum of digits in c program first we have to accept number from user and modulus that number with 10 (this will give us last digit of original number).
Store reminder in one variable and then add reminder in result variable. (keep default value of result variable as 0).
Now to remove last digit from original number divide it by 10 and store it in same variable.
Carry same steps with remaining number and we will get our result.
printf("Enter any number : ");
printf("Result is = %d",rsl);
Enter any number : 1234
Result is = 10
Connect with us on following platforms
PRACTICALS/PRACTICE PROGRAM IN C
CHECKOUT OTHER RELATED TOPICS
CHECKOUT OTHER QUIZZES
|Quizzes on Operator|
|Easy Quiz on Operators in C part 1|
|Easy quiz on operators in C part 2|
|Easy quiz on operators in C part 3|
|Quizzes on Loops|
|Easy quiz on loops in C part 1|
|Easy quiz on loops in C part 2|
|Easy quiz on loops in C part 3|
|Quizzes on Decision Making Statement|
|Easy Quiz On Decision Making Statements Part 1|
|Easy Quiz On Decision Making Statements Part 2|
|Quizzes on String|
|Easy quiz on String in C programming part 1|
|Quizzes on Array|
|Easy quiz on Array in C programming – part 1|
|5 – Best Java program to convert decimal to binary|
|New Quizzes Coming soon..|