I'm trying to make a function that adds the digits of a number together and finds the sum of them.

For example, for the number 9211, I want to add 9 + 2 + 1 + 1 and output the sum.

Here's my function, I can't figure out where I am going wrong.

Could someone point out why the result isn't coming out correctly?

```
#include <iostream>
using namespace std;
int SumFunction (int x)
{
int result = 0;
result = ((x % 10) + ((x / 10) % 10) + ((x / 100) % 10) + ((x / 1000) % 10) + ((x / 10000) % 10));
return (result);
}
```