Code for Program to sum the digit of each digit in C Programming
#include<stdio.h>
void main()
{
int a,sum,r;
sum=0;
printf("Enter the five digit number :");
if(scanf("%d",&a)==1)
{
for(;a>0;)
{
r=a%10;
sum=sum+r;
a=a/10;
}
printf("answer=%d",sum);
}
else
{
printf("Enter correct number");
}
}
=====================OUTPUT=====================
Enter the five digit number :12345
answer=15