I am trying to generate two different random numbers in C within a given range.The range is
0 to nk-1
But my following code sometimes works and sometimes fails.What is the reason behind this?
n1=rand()%nk;
n2=rand()%nk;
while(n1==n2)
{
srand(time(0));
n2=rand()%nk;
}