How do I convert an integer into digits and add their sum?

I'm working on an assignment for Computer Science 121. The assignment is to write a program that prompts a user to input an integer and then outputs both the individual digits of the number and the sum of the digits. For example, it should output the individual digits of 3456 as 3 4 5 6 and the sum as 18. I can't seem to get it working properly; I think my algorithm is wrong. I tried rewriting the algorithm, but I keep getting stuck in it. Can someone help me out? Here's what I have so far:

Start with the summation, because that's easy. You already seem to know about taking the remainder of ten to get the least significant digit and dividing by ten to slice it off. Remember to keep it as simple as possible. When you do this with more than one loop, you're not keeping it simple:

The fun part is getting the digits to print out from most significant to least significant, as per your example using 3456. If you just print num % 10 in the while loop, you can get the digits in reverse. To print in the right order, you need to store the digits somewhere (the simpler solution, IMO), or extract the digits from most significant to least significant.

The fun part is getting the digits to print out from most significant to least significant, as per your example using 3456. If you just print num % 10 in the while loop, you can get the digits in reverse. To print in the right order, you need to store the digits somewhere (the simpler solution, IMO), or extract the digits from most significant to least significant.

This is what i was thinking about from the go was to get them in the correct order, so maybe my post may give you a small clue

Thanks for the help, but I still can't seem to grasp how to output the digits in order. I can get them to output in reverse just fine, but when I try to get them to output in order I can't seem to figure it out. I just started learning c++ and just learned loops, so I don't know much code. Can I get some more clues? My Computer Science class starts in 15 minutes (last minute, I know >< Thought I could figure it out on my own).

Thanks again. One of the problems I did counted as a bonus and was actually worth more than this problem. I understand the solution now, and even though I didn't answer correctly I still scored a 100 because of the bonus question :)