mercredi 21 avril 2021

Taking data from iteration loops C

Essentially I'm trying to perform 100 iterations in where I compare a static int to an int that is randomised on every iteration, and a sum is kept of how many times in 100 the static int was larger than the rand.

My code looks something like this:

rand_int = (rand()% (5 - (-5) + 1)) - 5;
static_int = (50 + (y/100) * 40 + rand_int;
while (iteration != 100){
  iteration = 0
  iteration = iteration + 1
  randint2 = (rand() % (100 - 0 + 1));

and I've blanked from here.

EDIT 1: Set iteration to 0 outside of the while loop. I realise the silliness of having it inside, thank you for that it's very late for me haha.

EDIT 2: y is another variable I've used, not relevant static int is just equal to a formula I have written.




Aucun commentaire:

Enregistrer un commentaire