As for the others, they aren't related to my code, but rather my confusion.
http://prntscr.com/bquxs9
"The C++library provides a value-returning function named rand()that returns a random number.(The rand()function requires the directive #include <cstdlib>). The random number that is returned from the rand() function is an int. Here is an example of its usage:y = rand();After this statement executes, the variable will contain a random number."
I understand this part.
"The function uses an algorithm that produces the same sequence of numbers each time the program is repeated on the same system. For example, suppose the following statements are executed."
cout << rand() << endl;
cout << rand() << endl;
cout << rand() << endl;
The three numbers displayed will appear to be random, but each time the program runs,the same three values will be generated. In order to randomize the results of rand()."
What do they mean by the same system?
And why without srand() does rand() do this? It never explained why; it just said we need srand to make it random each time the program executes.
"The srand()function accepts an unsigned int argument, which acts as a seed value for the algorithm."
What's an unsigned argument and a seed value, and by the value acting as a seed value for the algorithm, do they mean they changing the algorithm inside the rand() function so that it produces different numbers each time a program is executed or does it change the algorithm inside the srand function?
"By specifying different seed values, rand()will generatedifferent sequences of random numbers."
But I still don't understand how this is related to srand()? Srand() produces a value that's somehow transported to each rand() statement so that each time the program is ran it executes different values because srand() changed the algorithm in rand()? Even so, how is it that without srand(), rand() makes the program print the same random numbers each time it's executed?
Is each specific rand() stored in the computer's memory in a way when it's executed it just shows those values, where when you add srand() it randomizes that value in the memory each time?
"A common practice for getting unique seed values is to call the time()function, which is part of the C++ standard library. The time()function returns the number of seconds that have elapsed since midnight, January 1, 1970. The time()function requires the directive #include <ctime>. When you call the time()function,you pass 0 as an argument."
http://prntscr.com/bqv6ug
Getting the system time makes sense, but I'm still having trouble understanding what an unsigned seed is or what a seed value is in general, thus I don't understand the step under it that says //seed the random number generator.
The image is also different from what I used in my slotmachine program, so I'm a bit off.
srand(time(0));
Why do we have to put time(0) even? Why not just time since it's going to give us a random number? I know when we call it that is passed 0 as an argument, but why is this necessary?
http://prntscr.com/bqvapz
How does 1+rand()%100=1-100?
If the random number was 99 why isn't it 99-100.
How does getting a remainder of a number=1-100.
I get why they have to add one in case rand() gets a number that goes into 100 evenly, but how all this is limiting the range of the random number and making it so that we can get a number between 1 and a 100 confuses me.