Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sum Of Digits added #54

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions Sum_of_digits.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/* Description of the code
This code provides the sum of digits of a given number.
eg:if the entered number is 234, the the sum of digits will be:
sum=2+3+4=9
so the desired output will be 9.
*/

#include<stdio.h>
int main()
{
int n,r,sum=0;
printf("Accept the number: ");
scanf("%d",&n);
while(n!=0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
printf("Sum of number %d",sum);
return 0;
}