#include
#include
void main()
{
int sum=0,n;
clrscr();
printf("Enter Value for Sum of Digits : ");
scanf("%d",&n);
do
{
sum=sum+(n%10);
n=n/10;
}while(n!=0);
printf("\tSum of Digits is %d",sum);
getch();
}
Output
Enter Value for Sum of Digits : 123
Sum of Digits is 6
No comments:
Post a Comment