I'm having a problem with the output of my program.

The "SumFunction" function adds the digits of a number together. For instance, the number 4532 would be 4 + 5 + 3 +2 and the output would equal 14.

the rest of the program determines if the last digit of the "SumFunction" of 2 user-given numbers are the same. If so, they are "Sum Buddies". The problem is that the code always says that any two numbers are Not Sum Buddies, even if they actually are.

It's a fairly simple code... Where am I going wrong?

The "SumFunction" function adds the digits of a number together. For instance, the number 4532 would be 4 + 5 + 3 +2 and the output would equal 14.

the rest of the program determines if the last digit of the "SumFunction" of 2 user-given numbers are the same. If so, they are "Sum Buddies". The problem is that the code always says that any two numbers are Not Sum Buddies, even if they actually are.

It's a fairly simple code... Where am I going wrong?

Code:

#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); } int main () { int a, b; cout << "Type Two Numbers: "; cin >> a >> b; if ((SumFunction(a) % 10) == (SumFunction(b) % 10)) { cout << a << " and " << b << " are sum pals." << endl; } else cout << a << " and " << b << " aren't sum pals." << endl;