How random function work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

How random function work?

anyone can explain to me how random function work?algorithm is enough

24th Nov 2016, 1:05 AM
Dariush Vesal
Dariush Vesal - avatar
2 Answers
+ 3
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main () { srand(time(0)); for (int x = 1; x <= 1000; x++) { //change x cout << 1 + (rand() % 1000) << endl; //you can change the range here above 1000 or watever you want } }
22nd Dec 2016, 4:51 AM
omàr Àli
omàr Àli - avatar
- 1
they do random things
24th Nov 2016, 2:38 PM
Jay Angue
Jay Angue - avatar