I found similar question on stackoverflow : How do I generate random numbers without rand() function?
I make little modifications for generating between 0-35 and final solution:
#include<stdio.h>
#include<time.h>
int main()
{
int num = 36;
time_t sec;
sec=time(NULL);
for(;;)
{
sec=sec%3600;
if(num>=sec)
{
printf("%ld\n",sec);
break;
}
sec=sec%num;
}
return 0;
}
Here we are using <time.h>
for time
instead of <stdlib.h>
for rand()
if we don’t want 0 as answer then we can add
while(sec==0)
{
sec=time(NULL);
}
before this statement : sec=sec%3600;
solved randomize numbers without any std- function