hi,

i think this would solve your question.

#include<iostream.h>
void main()
{
long int num=123456; int sum=0;
for(;num>0;sum+=num%10,num/=10);
cout<<sum;
}

// answer would be there in the variable sum

but if you want find sum of digits for numbers with more no of digits long int storage would not be sufficient.

Thanks,

Matrix


Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.

To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to