Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Program Randomly Generated Integers For this computer assignment, you are to

ID: 3741970 • Letter: C

Question

   C++ Program

Randomly Generated Integers For this computer assignment, you are to write a C++ program to generate random integers in the range l Low = 1 , HIGH = 100001 and to store them in a vector of size VEC-SIZE = 250. Then, sort the contents of the vector (in ascending order) and display it on stdout. To sort the contents of a vector, use the sort () function in the STL. In addition to the main (1 routine, implement the following subroutines in your program void genRndNums i vector& v | : This routine generates EC SIZE integers and puts them in vector v. Initializes the random number generator (RNG) by calling the function srand (SEED ) with the seed value SEED 1 and generates random integers by calling the function rand (). void printVec ( const vector & v) This routine displays the contents of vector v on stdout, printing exactly NO ITEMS 12 numbers on a single line, except perhaps the last line. The sorted numbers need to be properly aligned on the output. For each printed number, allocate ITEM W-5spaces on stdout. You are not allowed to use any I/O functions from the C library, such as scanf or printf. Instead, use the I/O functions from the C++ library, such as cin or cout. . . Name your source file asprog1.cg and your header file as prog1.h. Guard the statements in your header tile using the following format. (This is necessary because you don't want the statements in a header file are processed more than once #ifndef A-CONST-VALUE// should not be defined any place else "define A-CONST-VALUE // same const value as for ifndef directive - / put all statements for your header file here Wendif Include all system header files (that you need in your program) in your header file. For example, to gain access to the iostream library, which defines a set of simple I/O operations, insert the line #include in your header file, to gain access the I/O manipulators such as setw, insert the line #include iomanip> in your header file; to access the vector container in the STL, insert the line #include in your header file; and to use the functions in the

Explanation / Answer

#include #include #include #include #include #define LOW 1 #define HIGH 10000 #define VEC_SIZE 250 #define SEED 1 #define NO_ITEMS 12 #define ITEM_W 5 using namespace std; void genRndNums(vector &v) { srand(SEED); for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote