calculate sum in c++

C++
for (sum = 0; n > 0; sum += n % 10, n /= 10); //single line statement
                                              //where n=the imput number
Source

Also in C++: