Hi,
I am trying to solve this simple problem. It’s working well but not sure why failing with some of the test case:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
while(cin >> n){
int sum = 0;
while(n > 0){
sum += n%10 ;
n /=10;
}
cout <<sum<<endl;
}
}
Can someone have a look and guide me?