Program generates random numbers in the range


Discuss the below:

Q1: Implement the function "count" which takes a list of items and an item as arguments, and returns the number of times the item occurs in the list.

template < typename T >
int count (const list < T > & aList, const T& item);

Q2: Write a C++ program that generates 20 random numbers in the range from 0 to 4. For each number, output its value and insert it into an integer list by using push_back(). In a loop, call the above count function, and display the number of occurrences of each value (0 to 4) in the list.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Program generates random numbers in the range
Reference No:- TGS01937157

Now Priced at $25 (50% Discount)

Recommended (95%)

Rated (4.7/5)