The following code is generating -nan values.
Kindly help how to resolve.

int tmp1=rand()%n;
int tmp2=rand()%nd;
temp=array[tmp1][tmp2];
printf("temp=%f\n",temp);

Regards.