Are you at the high school level, undergraduate college, or graduate college level? That makes a difference, because at the graduate level you are expected to know a few things that can optimize this that undergrads and high school students don't usually know.
From a computational tractability perspective, you probably can't. You are iterating from 0 to 999999. While this is being done in O(n) time, which in the over scheme of things is pretty good, you are still iterating one million times. If you have to iterate all one million times, you are stuck at O(n), and all you can do is try to optimize the code a bit.
One change would be to unroll the loop. This would make it run much faster, but would result in a couple of million lines of code and a larger executable. This is a common compiler optimization technique, and can make your code run much faster.
Another change would be to take advantage of the parallelism offered by multi core cpus, or the gpu. If you have a good gpu, you might be able to get 100 threads running in parallel, and this would make it run 100 times faster. If you know how to write multi threaded code that can be off loaded to the gpu, this would be a trivial task.
Getting rid of the printf will speed things up. There is a bit of a penalty to pay to format the results like this. You could write a simple output function and buffer the results in memory, and then dump it when you are done. That could make it twice as fast because of the printf overhead.
You could try to write your own rand() function, but I'm not sure you can improve it much.
You might try g++ if you are using a Microsoft compiler. You might find that makes it run much faster as well. If you are running on Windows, try it on Linux and see how much faster it runs - sometimes getting rid of the bloat of Windows can make a big difference. I moved some of my OpenGL code to Linux and I was amazed at how much faster it was.
But in the end you still have a O(n) time function, and unless you are a computer science grad student, you are going to be stuck with that.