Skip to content
Snippets Groups Projects
Commit f888165b authored by Vignesh Vignesh's avatar Vignesh Vignesh
Browse files

sum of digits

parent 9c31968f
Branches master
No related tags found
No related merge requests found
#include<stdio.h>
int main()
{
int n;
int sum = 0 ;
printf("Enter the values = ");
scanf("%d",&n);
while(n>0){
sum += n % 10; // sum = sum + n % 10
n /= 10; // n = n/10
}
printf("%d\n",sum);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment