0
Write a program that inputs an integer and display the sum of its digits using while loop
2 Respostas
+ 15
int main() {
int x, sum=0;
cin>>x;
while(x!=0) {
sum+=x%10;
x/=10;
}
cout<<sum;
return 0;
}
0
int sum=0;
int num;
cin>>num;
while(num!=0)
{
sum+=num%10;
num\=10;
}
cout<<sum;