Thursday, December 9, 2010

C Prog to find Sum of the Digits

#include
int main()
{
int n,sum=0;
printf("Enter your Number");
scanf("%d",&n);

while(n!=0)
{
n=n%10;
sum=sum+n;
n=n/10;
}

printf("\n The Sum of Digits of Number You Entered is %d",sum);
}

OUTPUT
Enter your Number
56483126
The Sum of Digits of Number You Entered is 35



thanks,
Tushar Khoje




Download RealPlayer for FREE

No comments:

Post a Comment