Write a function that counts the occurrences of each digit in the string using the following header:

int * count(const string &s)
This function returns the counts as an array of 10 elements. For example, after invoking
int counts[] = count("2312ABcaB2")
counts[0] is 0, counts[1] is 1, and counts[2] is 3, etc.


```
#include
#include
using namespace std;

int* countLetters(string &s)
{
int* counts = new int[10];
for (int i = 0; i < 10; i++)
counts[i] = 0;

for (unsigned i = 0; i < s.size(); i++)
{
if (isdigit(s[i]))
counts[tolower(s[i]) - '0'] ++;
}

return counts;
}

int main()
{
string s = "001120191";
int* counts = countLetters(s);

for (int i = 0; i < 10; i++)
cout << (char)(i + '0') << " appears " << counts[i] << " times" << endl;

return 0;
}
```

Computer Science & Information Technology

You might also like to view...

Live Preview provides free online storage to people who have a Windows Live ID

Indicate whether the statement is true or false

Computer Science & Information Technology

Anonymity on the internet enhances the problems associated with _______.

A. Criminal use of cloud computing B. Legacy IT systems C. Reliability of cloud computing services D. The regulatory and legal environment

Computer Science & Information Technology