Question: I n C++, using namespace std; and only needs to use POINTER NOTATION, NO ARRAY NOTATION (Occurrences of each digit in a string) Write a

In C++, using namespace std; and only needs to use POINTER NOTATION, NO ARRAY NOTATION
(Occurrences of each digit in a string) 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"),
The output should look like:
counts[0] is 1
counts[1] is 1
counts[2] is 2
counts[3] is 2
counts[4] is 0
counts[5] is 0
counts[6] is 0
counts[7] is 0
counts[8] is 0
counts[9] is 0
Then, also write a main function to display the count for "SSN is 343 32 4545 and ID is 434 34 4323" and cout same as the previous.
Also, function should be redisigned to pass the counts array in a parameter as follows:
void count(const string &s, int counts [], int size);
where size is the size of the counts array. In this case, it is 10.
*11.6 (Occurrences of each digitin a string) Write a function that counts the occurrences 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 exam- ple, after executing int counts -count(" 12203AB3"),counts[O] 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" Redesign the function to pass the counts array in a parameter as follows: void count(const string& s, int counts[], int size) where size is the size of the counts array. In this case, it is 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
