How about sqrt( sin( PI * static_cast<double>( rand() / RAND_MAX ) ) ) ?
First ask the question more specifically.
Second, make your own attempt at writing the code and post what you have.
If you post code that compiles cleanly but doesn't work quite right you are more likely to get help than if you post non-compiling code or no code at all.