|
|
computerPick
or that can generate a new number each time the code goes round.
|
|
rand()
generates a random integer.rand() % 25
gives you the remainder of dividing this random number by 25, i.e. some number between (inclusive) 0 and 24.rand() % 25 + 25
rand() % 1 + 25
compAirCarr = rand() % 25 + 1;
See the difference? Order of operations is something that is easy to forget about, which is why you should always try to remember it.
That's not quite how it works :P Basically, rand() generates a random integer. rand() % 25 gives you the remainder of dividing this random number by 25, i.e. some number between (inclusive) 0 and 24. So they if you want a random number between 25 and 49 (inclusive), you just add 25 to it: rand() % 25 + 25 Your code: rand() % 1 + 25 Finds the remainder of the random number following division by 1 and adds 25. As Athar said, the remainder of division of any integer by 1 is 0, so this expression always returns 0 + 25 = 25. Hope this helps. Have you worked out what you need to do to get what you want now? |
25 + 25
thing was a scope...I just blindly went along with it :P but yes, thank you :)@OP: You can do that, but you have to write it correctly compAirCarr = rand() % 25 + 1; See the difference? Order of operations is something that is easy to forget about, which is why you should always try to remember it. |
computerPick |
I'm thinking I'll need some sort of accumulator array for it that compares the value input with the previous values? I'm not too sure how I'd go about it though. |
|
|
|
|