60 361
Assignments Done
98%
Successfully Done
In April 2018

# Answer to Question #45618 in C++ for kick

Question #45618
you are to write a C++ program to generate random
integers in the range [ LOW = 1, HIGH = 10000 ] and to store them in a vector &lt; int &gt; 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 from the STL. In addition to the
main ( ) routine, implement the following subroutines in your program:
&bull; void genRndNums ( vector &lt; int &gt;&amp; v ) : This routine generates VEC_SIZE integers and
puts them in vector v. Initializes the random number generator (RNG) by calling
the function srand ( ) with the seed value SEED = 1, and generates random integers
by calling the function rand ( ).&bull; void printVec ( const vector &lt; int &gt;&amp; 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 = 5 spaces on stdout.
#include &lt;iostream&gt;#include &lt;vector&gt;#include &lt;cstdlib&gt;#include &lt;ctime&gt;#include &lt;algorithm&gt;void genarateRandomNumbers(std::vector&lt;int&gt;* numbers) {    for ( int i = 0; i &lt; 250 ; i++ ) {      &nbsp; numbers-&gt;push_back(1 + rand()% 1000);    }}int main() {    srand(time(NULL));    std::vector&lt;int&gt;* numbers = new std::vector&lt;int&gt;();    genarateRandomNumbers(numbers);    std::sort(numbers-&gt;begin(), numbers-&gt;end());    for ( std::vector&lt;int&gt;::iterator it = numbers-&gt;begin(); it != numbers-&gt;end(); it++ ) {      &nbsp; std::cout &lt;&lt; *it &lt;&lt; &quot; &quot;;    }}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!