#include <iostream>
using namespace std;
int main() {
string a;
int sum = 0;
getline(cin, a);
for(int i = 0; i<a.length(); ++i) {
string temp; temp += a[i];
sum+=atoi(temp.c_str());
}
cout << endl << "Sum: " << sum;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main() {
string a;
int sum = 0;
getline(cin, a);
for(int i = 0; i<a.length(); ++i) {
string temp; temp += a[i];
sum+=atoi(temp.c_str());
}
cout << endl << "Sum: " << sum;
}