k I am being asked to Write a function sumArrayAscii that accepts an array of strings and returns the sum of all the ascii values of all the characters in all the strings in that array. Note that this function should use sumAscii from problem. this is what I have but I cannot get it ti work
#include <iostream>
using std::cout;
using std::endl;
int main()
{
int myArrayNumberOfElements(5);
double myArray[myArrayNumberOfElements] = {1.1, 4.5, 5.7, 7.9, 10};
double sum(0);
for (int i(0); i < myArrayNumberOfElements; i++)
{
sum +=myArray[i];
}
cout << endl << "Sum of all elements: " << sum << endl;
system("PAUSE");
return 0;
The code that you posted calculates the sum of a double array. I see no work with strings or ASCII code for that matter.
These two function worked for me. First function returns the ASCII sum of all characters in a single string. The second one uses the first function in calculating the ASCII sum for a list of strings.