what would be a good way to go about summing the digits of an int for example say i put in 3456 the sum of thos would be 18 but i have no idea how to get the numbers to sum from a single integer

I would use std::stringstream to put the int into a stirng. Then the logic is much more straight forward to get each digit of the string. You can again use stringstream to get each one back to an int before adding them.

iamthewee's option also works, but it could be more confusing to read in my opinion.

int splitsum= 0;
void splitadd(unsigned int n){
int d = n % 10; n = n / 10; if ( n > 0) splitadd (n); splitsum += d;}
...
// in main() add this:
splitadd(12345); cout << "Result: " << splitsum << endl; // Result: 15

hi! I want to create a procedure which execute given below query using dynamic sql. i am getting some error i.e. "Msg 156, Level 15, State 1, Line 1
Incorrect ...