#include using namespace std;
int main() { int n; int sum=0; cin>>n; int arr[n]; for(int i =0;i<=n;i++) { cin>>arr[i]; while(arr[i]>0) { sum = sum+(arr[i]%10); arr[i] = arr[i]/10; } cout<<sum<<endl; }
// your code here return 0;
}
You don’t zero the sum between numbers.
But did you notice how big the number can be? up to 10^50. You can’t read that into an int.
Thank you!, so which type of data type should i use?
Think about the possibilities, and choose the one you think best.