#include <stdlib.h>
#include <time.h>
int main(){
for(int i = 0; i < 10; i++){
srand(time(NULL));
int computer = (rand() / ((double) RAND_MAX + 1)) * 5;
printf("%d\n", computer);
}
return 0;
}
I'm new to programming and this is what I have done so far. The problem is that it will generate a random number and print that same number 10 times instead of printing out 10 random numbers. How do I solve this?
Aucun commentaire:
Enregistrer un commentaire