Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions