//Natalie Zarate
#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;
/*******************************************************************************
* digitsSum
*
* THis function will compute the sum of the series of numbers provided by the
* user
* ______________________________________
// Prototype for digitsSum
int digitsSum(cont char *string);
// Prototype for maxDigit
char maxDigit(const char *string);
// Prototype for minDigit
char minDigit(const char *string);
int main()
{
char numbers[5];
int sum;
// Prompt user for a series of single digit numbers
cout << "Enter a series of 4 single digit numbers: " << endl;
cin.getline(numbers, sizeof(numbers));
// Call digitsSum
sum = digitsSum(numbers);
return 0;
}
int digitsSum(const char *string)
{
int sum = 0; // OUTPUT - su of inputted series
// Step through array
while(*string)
{
if(digits(*string))
{
sum += atoi(string);
}
// Move to next element
string++
}
return sum;
}
Ly9OYXRhbGllIFphcmF0ZQojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxjc3RyaW5nPgojaW5jbHVkZSA8Y2N0eXBlPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLyoqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioKICogZGlnaXRzU3VtCiAqIAogKiBUSGlzIGZ1bmN0aW9uIHdpbGwgY29tcHV0ZSB0aGUgc3VtIG9mIHRoZSBzZXJpZXMgb2YgbnVtYmVycyBwcm92aWRlZCBieSB0aGUgCiAqIHVzZXIKICogX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KLy8gUHJvdG90eXBlIGZvciBkaWdpdHNTdW0KaW50IGRpZ2l0c1N1bShjb250IGNoYXIgKnN0cmluZyk7CgovLyBQcm90b3R5cGUgZm9yIG1heERpZ2l0CmNoYXIgbWF4RGlnaXQoY29uc3QgY2hhciAqc3RyaW5nKTsKCi8vIFByb3RvdHlwZSBmb3IgbWluRGlnaXQKY2hhciBtaW5EaWdpdChjb25zdCBjaGFyICpzdHJpbmcpOwoKaW50IG1haW4oKSAKewoJY2hhciBudW1iZXJzWzVdO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