Skip to content
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;
}