I\'m trying to learn c++ on my own and I\'ve hit a bit of a road block. The problem is I need to take an integer,split it into its digits and get the sum of the digits and
digit = number % 10;
This operation will return the the right most number.
so when you try to your app with an input "1357", on the first run through the while loop, it will return 7. Next it will return 5, and so on.
If all you want is the sum of the individual digits, then the order you get them (and print them out) will not affect the final answer. If you still want them to printed in the correct order, you can store the digits in an array (or Vector or Stack, as others have mentioned), reverse the contents, and then loop through the structure, to print out its contents.