1234567891011121314151617181920212223
#include <iostream> using namespace std; int main() { int num; int sum = 0; cout << " Enter a number : "; cin >> num; while ( num > 0 ) { sum += num % 10; num /= 10; } cout << "Sum = " << sum; return 0; }
sum += (num % 10) * (num % 10) * (num % 10);
12
// #include <math.h> sum += pow(num % 10, 3);