I've recently written a little program to test the C rand function found in <math.h>
.
I've compiled it twice and run it multiple times. On every run, the same output was printed out:
2
2
6
3
5
3
Can someone point out the problem?
Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int pick(int start, int end){
int num = ( rand()%end ) + start;
return num;
}
int main(){
int i;
for(i=0; i<6; i++){
printf("%d\n", pick(1, 6));
}
return 0;
}