You are here:

C/unique values by rand( )

Advertisement


Question
rand( ) has the tendency to be non random , particularly for lower range numbers.
This is causing problem to me in my simulation as I need all the values, that too generated only once.
How to efficiently, either by an inline code or some library , get a rand( ) to return all unique values while covering all the values.

Regards,
Jitender

Answer
I didn't find any problem with the rand() fnction . even after using the srand() function ,

Its Pretty well and working fine , moreover it didn't generate any redundant value !

if still the problem presist ill send you some random generator function later !  

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Prince M. Premnath

Expertise


I'm sure that I can solve any doubts in Turbo C ,Graphics Programing ,Mouse, Hardware Programming ,File System ,Interrupts, BIOS handling , TSR Programming , General Concepts in C Language, handling inline Assembly statements

Experience

Research over 6+ Years

Organizations
CG-VAK Softwares and Exports Limited

Education/Credentials
Masters in Computer Applications

©2012 About.com, a part of The New York Times Company. All rights reserved.