In my CPP system whenever I generate a random number using rand() I always get a value between 0-32k while in some online videos and codes it is generating a value between 0-INT_MAX. I know it is dependent on RAND_MAX. So it there some way to change this value such that generated random number are of the range 0-INT_MAX Thanks in advance for the help :)
#include<bits/stdc++.h>
using namespace std;
int main(){
srand(time(NULL));
for(int i=1;i<=10;i++){
cout << rand() << endl;
}
}
I used this code and the random number generated are 5594 27457 5076 5621 31096 14572 1415 25601 3110 22442
While the same code on online compiler gives 928364519 654230200 161024542 1580424748 35757021 1053491036 1968560769 1149314029 524600584 2043083516
Aucun commentaire:
Enregistrer un commentaire