Horje
C++ sum the digits of an integer Code Example
sum of digits in c++
int x, s = 0;
   cout << "Enter the number : ";
   cin >> x;
   while (x != 0) {
      s = s + x % 10;
      x = x / 10;
   }
C++ sum the digits of an integer
// sum the digits of an integer
int getSum(long long n) {
  int sum = 0;
  int m = n;
  while(n > 0) {    
    m = n % 10;    
    sum = sum + m;    
    n = n / 10;    
  } 
  return sum;
}




Cpp

Related
qt disable resizing window Code Example qt disable resizing window Code Example
prime numbers less than a given number c++ Code Example prime numbers less than a given number c++ Code Example
how to read a comma delimited file into an array c++ Code Example how to read a comma delimited file into an array c++ Code Example
function overloading in c++ Code Example function overloading in c++ Code Example
c++ hours minutes seconds Code Example c++ hours minutes seconds Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8