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

c++ Programming languange 1. What is the smallest value that the random number g

ID: 641100 • Letter: C

Question

c++ Programming languange

1. What is the smallest value that the random number generator will return?

2.What is the largest value the random number generator will return?

3.Give two reasons why we might want to seed the random number generator.

4.What is a good way to get a different random number seed each time we run the program?

5.To generate a different random sequence every time the program is run, should you call the random number seeding function for every random number you generate? Why or why not?

Explanation / Answer

int rand_int(int limit1, int limit2)
{
return rand()%(limit2-limit1+1) +heads;

}

1)smallest value = limit1
2)largest value = limit2
3)when we want to fill junk data automatically within our limits
4)implement this to get unique random numbers
HashSet<Integer> randomNumbers = new HashSet<Integer>();

for (i = 0; i < g; i++) {
e = rand.nextInt(20);
randomNumbers.add(e);
if (randomNumbers.size() <= 10) {
if (randomNumbers.size() == 10) {
g = 10;
}
g++;
randomNumbers.add(e);
}
}
5) every time we have to call

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