How many natural numbers less than $10^8$ are there, whose sum of digits equals $7$? 
How many natural numbers less than $10^8$ are there, whose sum of digits equals $7$? 

I got it here.But is there any more effecient and easier way to solve than the link shows?

C++ program for your problem:
#include < iostream>
using namespace std;
int main() {
int count=0;
int sum(int x);
for (int i=1;i<100000000;i++){
if (sum(i)==7)
count++;

}
cout < < count< < endl;
return 0;
}
int sum (int x){
int add=0;
while(x){

add=add+x%10;
x=x/10;
}

return add;
}
