Generates random numbers in a given range using malloc function in stdlib.h. Based on the observation that the memory address allocated during malloc is usually 'random' (for humans). takes in two arguments- start of range, end of range.
1 2 3 4 5 6 7 8 9 | int random(int start,int end){
int h;
float k;
h=(int)malloc(sizeof(int));
h=h%10000;
k=((float)h)/10000;
k=start+(end-start)*k;
return k;
}
|