What are the other options? Is this multiple choice or just fill in the blank
Sorry I don't understand your question
Answer:
C++.
Explanation:
#include <iostream>
#include <string>
using namespace std;
////////////////////////////////////////////////////////////////////////////
int sumDigits(string alphanumeric) {
if (alphanumeric.length() == 1) {
if ((int(alphanumeric[0]) >= 48) && (int(alphanumeric[0]) <= 57)) {
cout<<int(alphanumeric[0]) - 48<<endl;
return (int(alphanumeric[0]) - 48);
}
else
return 0;
}
else {
if ((int(alphanumeric[0]) >= 48) && (int(alphanumeric[0]) <= 57)) {
cout<<int(alphanumeric[0]) - 48<<endl;
return int(alphanumeric[0]) - 48 + sumDigits(alphanumeric.substr(1, alphanumeric.length()-1));
}
else
return 0 + sumDigits(alphanumeric.substr(1, alphanumeric.length()-1));
}
}
////////////////////////////////////////////////////////////////////////////
int main() {
cout<<"Sum: "<<sumDigits("ab1c2d3e54");
return 0;
}
Answer:
1 1 1 1 1 1
Explanation:
You copy the first location to the second, and then the second to the third, and so on. Effectively the value of the first location (1) is copied to all locations.