You are here:

C++/random function in c++


I wish to make a program to solve can i generate random numbers in c++ language??

Dear Kulbeer:

"The ANSI C standard only states that rand() is a random number generator which generates integers in the range [0,RAND_MAX] inclusive, with RAND_MAX being a value defined in stdlib.h, and RAND_MAX being at least 32767. Note that 32767 isn't a very big number. If RAND_MAX is only 32767 then you can probably get only about 20,000 random numbers before the sequence starts to lose its randomness. Note that RAND_MAX may be larger. Check what the value of RAND_MAX is for you. A rule of thumb is you can generate around 2/3 of RAND_MAX random numbers before it becomes obvious what the remaining numbers are going to be and the sequence loses its randomness. To be safe I recommend generating no more than 1/10 of RAND_MAX random numbers.1"  


All Answers

Answers by Expert:

Ask Experts


Titus B. Ledbetter, Jr.


C , MFC, Object Oriented, Artificial Intelligence


I have over ten years experience in the field of Computer Science, five years experience developing C/C++. I recently wrote a chess program using Object Oriented, C++, MFC.

Master's Degree Computer Science from Johns Hopkins

©2017 All rights reserved.