so i have a while loop, each time it runs i want it to take in account each previous number that was randomly selected. When i run the loop i want it to create a new number every time the user says so, and at the same time taking in account the new numbers generated in the loop already, This code doesnt work, it wont take into account the new numbers generated. So i have this:
do you have your full code? and could you please use the <> code thing in the format making it easier to read
Also the reason you cannot get a different 5th number is becuase there are no such as a real random number. There are only psuedo random numbers.
if you want to get "good" psuedo random numbers
srand(time(NULL)); //this will give you a new random number in your program every time you run it.
then to generate new random number within the program create a variable to hold the "random" number and multiply by an interger then multiply it by % " what ever you want here"
this what it might look like
ran = (rand() * 33); //storing rand() * 33 into the variable ran (this will give you a high integer value that is seemingly random
ran = (rand() % 100 ) + 1; //this will take the integer value you just generated mod 100 + 1 to give you a "random" number between 1-100
if this was somewhat conusing here is a program i made that will generate a random number 10,000 times that is bewteen 1-100 and will store any number less than 75 into counter A and any number greater than 75 into counter B
Here is my attempt at generating only unique numbers. It doesn't ever repeat the same number twice in a row, it also allows the user to contiguously generate new unique numbers until they type anything other than 'y'.
You can change the number after the modulo symbol to set the range to any amount of numbers you wish ( i.e... randNum.push_back(1 + rand() % 5000); ) , I just used 2 as a test.