Question: Write a program that prints the frequency (# of occurrences) of each unique number inside a given set of numbers. For example: Given set of

Write a program that prints the frequency (# of occurrences) of each unique number inside a given set of numbers. For example: Given set of {1,1,2,2,2,4,5,5,7,7,7}, your program should output: 1:2 2:3 4:1 5:2 7:3 Your program will be based on the following template. Copy this code as your starting point for your code. Use the test vector given in the main function. Make sure you put in the correct header files and function prototypes. Complete each function to implement the desired results. **********************************************************************************

include your headers here

int main() {

std::vector tst = {1,2,1,3,3,2,3,2,4}; // our test array

printFrequency(tst); return 0;

}

// Helper function that returns how many of item is in

// the input array.

int countItem( put arguments here...) {

int count = 0; // initialize the counter variable to zero

put your code here

return count;

}

// Function that prints out the frequency of each unique

// item in the input array

void printFrequency( put arguments here...) {

put your code here

}

I know, how to code it using only the main function; however, the assignment requires the use of main, printFrequency, and countItem. The use of functions confuses me so I can't figure out how to implement this into code using three functions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!