Hello there, I'm trying to answer this question '2-3. Write a function that given an array of integers and the length of the array, will count the amount of times the numbers 2, 5 and 9 appear using a switch statement. The function must print out your results on one line in the following form:
2:<num_twos>;5:<num_fives>;9:<num_nines>;
If the array contained three 2s, one 5 and eleven 9s, the output would be:
```2:3;5:1;9:11;```
Note the colons and semi-colons. Also remember to write out a newline at the end of the output. The function must still produce a line of output even if the size parameter, n, is less than 1.
Signature: void two_five_nine(int array[], int n)'
The format requires 2 files,
main.cpp:
#include <string>
extern void two_five_nine(int array[], int n, int& num_twos, int& num_fives, int& num_nines);
int main() {
int arr[] = {2, 5, 9, 2, 9, 9, 5, 2};
int size = sizeof(arr) / sizeof(arr[0]);
int num_twos, num_fives, num_nines;
two_five_nine(arr, size, num_twos, num_fives, num_nines);
std::cout << "2:" << num_twos << ";5:" << num_fives << ";9:" << num_nines << ";" << std::endl;
return 0;
}```
and function.cpp:
```void two_five_nine(int array[], int n, int& num_twos, int& num_fives, int& num_nines) {
num_twos = 0;
num_fives = 0;
num_nines = 0;
for (int i = 0; i < n; ++i) {
switch (array[i]) {
case 2:
num_twos++;
break;
case 5:
num_fives++;
break;
case 9:
num_nines++;
break;
}
}
}