PROGRAM:
#include<stdio.h>
main()
{
int n,i,sum=0;
printf("Enter
a Number\n"); scanf("%d",&n);
do
{
i=n%10;
sum=sum+i;
n=n/10;
}while(n>0);
printf("The Sum of
digit is %d\n",sum);
}
OUTPUT:
Enter
a Number 5891
The Sum of digit is 23
No comments:
Post a Comment