A problem that lets the user enter any positive integer, but you do not have to check for this,
and then calculates the sum of the digits and displays this to user. For example, if user enters
14503, the outputted sum of the digits would be 13.
here us my program
#include <iostream>
int main(void)
{
int integer, sum=0;
while(integer)
{
sum += integer % 10;
integer /= 10;
}
cout << "The sum of the integers numbers is " <<sum;
return 0;
}
{
int Integer, Sum=0;
cout << "Enter an integer --> ";
cin >> Integer;
while(Integer>0)
{
Sum += Integer % 10;
Integer /= 10;
}
cout << "The sum of the integers numbers is " <<Sum;
return 0;
}