Are you repeatedly seeding every time? If you seed before every rand() there's sometimes trouble since the seeds happen much faster than the time changes. Also change the remainder assignment like rabidgnome mentioned.
I just wrote this quickly and it worked fine:
Edit: I verified my suspicion above by seeding in the loop. When you seed over and over again, you'll effectively get the same result from rand. As I mentioned before, it may seed and generate 50 or 100 times in your code, but because the computer clock is going so much faster than the system time, the random number is effectively generated as the same thing. Long story short: seed once, and only once, at the start of your code and use rand() all the other times.
Code:
#include <stdio.h>
#include <stdlib.h>
int main(void){
int remainder;
int i;
srand( time(0) );
for(i=0;i<50;i++){
remainder = (rand() % 6)+1;
printf ("nRandom Number from 16 is %d", remainder);
}
getchar();
return 0;
}
The result was:
Quote:
Random Number from 16 is 6
Random Number from 16 is 1
Random Number from 16 is 2
Random Number from 16 is 4
Random Number from 16 is 6
Random Number from 16 is 6
Random Number from 16 is 3
Random Number from 16 is 3
Random Number from 16 is 3
Random Number from 16 is 3
Random Number from 16 is 5
Random Number from 16 is 2
Random Number from 16 is 6
Random Number from 16 is 6
Random Number from 16 is 1
Random Number from 16 is 4
Random Number from 16 is 6
Random Number from 16 is 2
Random Number from 16 is 2
Random Number from 16 is 5
Random Number from 16 is 2
Random Number from 16 is 1
Random Number from 16 is 2
Random Number from 16 is 6
Random Number from 16 is 6
Random Number from 16 is 5
Random Number from 16 is 5
Random Number from 16 is 6
Random Number from 16 is 4
Random Number from 16 is 6
Random Number from 16 is 5
Random Number from 16 is 1
Random Number from 16 is 5
Random Number from 16 is 4
Random Number from 16 is 5
Random Number from 16 is 1
Random Number from 16 is 6
Random Number from 16 is 3
Random Number from 16 is 2
Random Number from 16 is 5
Random Number from 16 is 5
Random Number from 16 is 6
Random Number from 16 is 1
Random Number from 16 is 3
Random Number from 16 is 5
Random Number from 16 is 1
Random Number from 16 is 2
Random Number from 16 is 5
Random Number from 16 is 1
Random Number from 16 is 6
