For(i=0 to 10)
printf(%d\t%d,rand()%100,rand()%100);
It always prints the same set of values. Can someone explain to me why?
For(i=0 to 10)
printf(%d\t%d,rand()%100,rand()%100);
It always prints the same set of values. Can someone explain to me why?
The rand() function generates random numbers with a given "seed" number. When you dont specify the seed rand() will give you the same output every time.
To set a seed use srand(time(NULL)); to make use of the computers internal clock to set the seed. Dont forget to include time.h in order to have access to the time() function.