Code:
#include <iostream>
using namespace std;
//--------------------------------------------------------------------------
int csum(int);
int getcsumforrange(int);
//--------------------------------------------------------------------------
int main(void){
cout << getcsumforrange(1000000);
cin.get();
return 0;
}
//--------------------------------------------------------------------------
int csum(int iNumber){
int iChecksum = 0;
do{
iChecksum += iNumber % 10;
iNumber /= 10;
}while(iNumber > 0);
return iChecksum;
}
//--------------------------------------------------------------------------
int getcsumforrange(int iRange){
int iRangechecksum = 0;
for(int i = 0; i <= iRange; i++){
iRangechecksum += csum(i);
}
return iRangechecksum;
}