What is the range of rand() | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the range of rand()

what is the min and max value returned by the rand() function in C++?

25th Dec 2016, 5:24 PM
ifl
ifl - avatar
5 Answers
+ 1
@K2 Shape. rand return int, yes. But standart guarantees only [0; 32767]. On some compilers the range could be wider.
25th Dec 2016, 6:04 PM
Vladislav
Vladislav - avatar
+ 2
The range is from 0 to 2^64
25th Dec 2016, 6:03 PM
Wen Qin
Wen Qin - avatar
0
The min: 0 The max: 32767 (in some compilers can be larger)
25th Dec 2016, 5:41 PM
Vladislav
Vladislav - avatar
0
I know it's nixe to ask here but its an important step to start learning to use the official C++ documentation. It's not really more work and you will get your answer immediately.
25th Dec 2016, 5:48 PM
Andreas K
Andreas K - avatar
0
And int is the 32bit variable and can store 2^32 numbers
25th Dec 2016, 6:05 PM
Vladislav
Vladislav - avatar