Is it possible? Yes. Do I know how to do it? Not really. I mean, you can probably open and close a few other applications and it will change what RAM is available, but I don't really know how all of that works and I believe it comes down to the OS's architecture.
Why do you want to do that? Granted, let's say that you want to try to get the variable to have the same memory location every time. There is several issues with that.
1) Every time that you run your program, that memory location might be in use by another program or your OS. Trying to access that information will signal errors and eventually your program will crash (the purpose behind this is to "prevent" malicious programs, or unintentional programs, from modifying other program information). The OS has strict rules on what can access other program memory, and typically it's just not allowed.
2) Even if you manage to get the same memory location each time, you're not even guaranteed that it had the same value stored in it from even 5 seconds ago. Depending on your system, your RAM might flash itself, your compiler might set a default value for said variable, or even another program could have used that memory since you last used it.
3) It would serve no purpose to your program which memory location you actually got. We don't build out applications around the memory locations, just that we may need to allocate x amount of memory for doing y.
With those three things, I can also apply it to manually changing the memory locations each time.
1) Sometimes you just get what you're handed. If memory location x is available every time your program runs, and your program is forced to use it, sucks to be you.
2) Even if you can find a way to change the location, it wouldn't serve any purpose to the information that's in it. Let's say you just did a fresh restart of your computer. That memory may not have even been touched yet, let alone countless other locations. They would be nothing in there, garbage values, etc.
3) Let's say you find someway to do it, and find a use even after the above steps. Where would you possibly ever need this? The garbage values stored at that location won't help you fix anything. Programs that rely on secretive information can manually change the values before exiting. You can't access them while they're running anyways. The memory location itself really doesn't matter, not that I've ever seen.
With all of that, I wouldn't see why you would need such a thing. I'm not a computer science major by any means, but I believe I've explained that correctly (I'm sure someone will correct me if I didn't). The thing that matters about memory locations is that we have the correct number of
consecutive blocks of memory for a certain object. Typically, the only other time memory location actually matters is during debugging and if you're interested in seeing how things work.
This is getting into the deeper end of computers, and something I'm not comfortable with, actually, I'm not comfortable with any of the stuff I covered this far.
Something, however, that I can help you with is the rand() function. It's located in cstdlib and you can read more about it here:
http://www.cplusplus.com/reference/cstdlib/rand/
Please note: Before using rand, it's typically practical to use the srand function to seed it. rand isn't actually random numbers, and seeding only tells the compiler which set of numbers to read from. Now, that can be a conversation in itself, but most commonly, srand is placed at the very beginning of main (the only function that shouldn't be called more than once) and is passed the parameter of time(0). time can be found in the ctime header. Again, long story short, it returns the number of seconds from when your program was launched since 1/1/1970. It's unlikely you're going to run your program twice in a second, so it's a good "random" seed.
Without seeding, you will get the same "random" numbers.
Hope all of this helps.