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

int * count(const string &s)

The function counts how many times a digit appears in the string. The return value is an array of ten elements, each of which holds the count for a digit. For example, after executing int counts[] = count("12203AB3"), counts[0] is 1, counts[1] is 1, counts[2] is 2, counts[3] is 2.
Write a main function to display the count for "SSN is 343 32 4545 and ID is 434 34 4323".

```
#include
#include
using namespace std;

int * count(const char * const s)
{
int * counts = new int[10];
for (int i = 0; i < 10; i++)
counts[i] = 0;

for (int i = 0; i < strlen(s); i++)
{
if (isdigit(s[i]))
counts[s[i] - '0'] ++;
}

return counts;
}

int main()
{

int * counts = count("SSN is 343 32 4545 and ID is 434 34 4323");

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

return 0;
}
```

Computer Science & Information Technology

You might also like to view...

To open the panel in the accompanying figure, click the Assets tab in the ____ panel group,

A. Files B. Images C. Resources D. Site

Computer Science & Information Technology

?Tangible costs are costs whose dollar value cannot be calculated easily.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology