Write a program that uses an STL container to store integers solved

Write a program that uses an STL container to store integers solved

Write a program that uses an STL container to store integers.

1) Write a loop that generates 10,000 random integers between 1 and 100 ad store them in an STL vector.

2) Print the first 500 numbers in the vector, nicely formatted, 15 numbers per row.

3) Sort the vector, smallest to largest, using the "sort algorithm" provided by STL.

4) Print the first 500 numbers in the vector, nicely formatted, 15 numbers per row.

5) Print the sum of all the numbers.

6) Print the average of all numbers.

7) Print the mode of all numbers (the mode is the umber that appears most often). If there is a tie for mode, print the smallest of the tie.

8) Print the frequency of the numbers, one number per row: Print the numbers 1 through 100 followed by a colon, followed by the number of times that number appears in the STL container.

 
Powered by