New course! Every coder should learn Generative AI!
Try a free lesson+ 2
The rand function know a "random" order of numbers (can be using an array of a cyclic suite) where each number can appear more than once.
The seed is the starting point in the order.
So if you use a constant seed (see example below), you will always have the same result.
Try this code 2 or 3 times and you will see :
#include <cstdlib>
#include <iostream>
using namespace std;
int main(){
srand(5);
for(int i=0;i<10;++i)
cout<<rand()<<endl;
return 0;
}