I want to do a multiplications quiz using random numbers from 2 variables. I tried to use this:
int answ
int rand1= (arc4random()%10)+1;
int rand2= (arc4random()%20)+1;
printf("\n¿What is %d * %d?: ", rand1, rand2);
scanf("%d", &answ);
if (answ==rand1*rand2)
printf("\nCorrect answer!");
else
printf("\Incorrect answer, the result was %d", rand1*rand2);
My problem is that both random numbers does not change when the next question is asked. I also tried adding srand(time(NULL)) and the same.. (I already have the library stdlib.h added)
What´s missing?
Aucun commentaire:
Enregistrer un commentaire