need some guidance.....

i got a file with some numbers for example 1234 and 3302 and i need to add 1+2+3+4 to equal 10 and lets say 3+3+0+2 equal 8. i got this while loop but how do I use a counter and where do i put it..to add the digits and show on an output 6 and 8

while(fin>>number)
{
if(number<=0)
{
cout<<"bad data"<<number<<endl;
continue;
}
fout<<number<<endl;

while(number > 0 )
{
remainder =number % 10;

number = number / 10;
}
All I can recommend is reading a bunch of tutorials and maybe a c++ book or two.
Topic archived. No new replies allowed.