Random Number

Jan 17, 2020 at 5:36pm
What will be tha output of random numbers in line below?

 
 if((abs(pid)==5 && rand()%100<60) || (abs(pid)==4 && rand()%100<10)){
Last edited on Jan 17, 2020 at 5:37pm
Jan 17, 2020 at 5:41pm
nothing.
the random numbers are being used to decide whether to enter the if statement executed block which you left out. There is no output here.

this code is like saying
roll a 6 sided die
if the die is 1,2 or 3, then do something.
if not, do not do anything.

why not use <random> here?
Last edited on Jan 17, 2020 at 5:42pm
Topic archived. No new replies allowed.