I've knocked together a little solution which works with int's but i'm afraid 8790278573 doesnt fit in an int (on my computer at least). You can see the method i used anyway:
Code:
#include<iostream>
using namespace std;
int main() {
int i = 790278573; // Number you want to add the digits of
int icopy = i;
int result = 0;
while(icopy > 0) {
result += icopy % 10;
icopy /= 10;
}
cout << "Initial number: " << i << "\n";
cout << "Sum of digits : " << result << "\n";
}
I'd like to see a better method if anyone would like to post one. I'm not that hot on C++
Hope this helps anyway