The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 3 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
In C++.
Â
Create a function/method/procedure that
returns a random number from the following set, {8,51,78,111,121}. Loop 10000 times with this procedure and print the frequency of each of the 5 numbers obtained. Hint: Use an array for the sequence and frequency. The following is a brief hint on items that might be helpful in obtaining the results. This is not direct code but more pseudo code related. Don't try and run the following directly and more code will be needed.
Setup
const int n=5,ntimes=10000; int freq[n]={0}; short int rndseq[]={8,51,78,111,121}; Call to the routine to return a random sequence retrand(rndseq,freq,n,ntimes); Results cout<<rndseq[i]<<" occured "<< freq[i]<<" times"<<endl; Sample Output 8 occured 2055 times 51 occured 1986 times 78 occured 1962 times 111 occured 2079 times 121 occured 1919 times Note: Your results are not expected to be exactly the same! After all these are pseudo-random number sequences with different seeds. */
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------sol-----------uti-----------on.-----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- ca-----------tch-----------