#include<iostream>
using namespace std;
int main() {
int num;
int sum_digits=0;
cout << "Enter a number : ";
cin >> num;
while (num != 0)
{
sum_digits = sum_digits + num % 10;
num = num / 10;
}
cout << "The sum of the digits is : "<< sum_digits<<endl;
return 0;
}
Comments
Leave a comment