# Extracting and comparing numbers

This is a discussion on Extracting and comparing numbers within the C++ Programming forums, part of the General Programming Boards category; Ok I found the solution. I initialized 'total' (my int for finding the combined total of all numbers) to equal ...

1. Ok I found the solution. I initialized 'total' (my int for finding the combined total of all numbers) to equal 0 then I did this:

Code:
```if( num != 0 ){
while (num != 0){

currentNum = num % 10;
num /= 10;

cout <<"curr:" << currentNum << endl;
total += currentNum;
cout<< "total:" << total << endl;

if( currentNum > largeNum ){
largeNum = currentNum;

}
if( currentNum < smallNum ){
smallNum = currentNum;
}

}
}
else{
largeNum = 0;
smallNum = 0;
total = 0;
}```

2. Thanks a lot for all the help and the time you took out to help me. It probably took a lot of patience to put up with my amateurism. Thanks again!

3. Don't forget those logic lessons now. They weren't meant to solve the problem, but rather to enable you to think like a computer to solve any general problem.

Page 4 of 4 First 1234