I need to make a bool that will return true if (1 + (rand() % 101)) <= 50 , otherwise return false .

I want to make it so that if bool == true , then execute the function, if not, do not.

Through if (mybool == true) did not work.

Closed due to the fact that the essence of the question is not clear to the participants of VTT , Fat-Zer , Kromster , 0xdb , MSDN.WhiteKnight May 21 '18 at 9:17 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • bool what? function? what is the problem, not very clear, everything is already written - Swift

1 answer 1

But what's the problem?

 if ((1 + (rand() % 101)) <= 50) call_function(); 
  • My code looks something like this: void CSetup :: Run () {... if (Settings :: Myfunc) {// here is the execution code} ...} Do you need me to do this logically according to logic? if (Settings :: Myfunc && ((1 + (rand ()% 101)) <= 50)) {...} - Greorghe Lanescu
  • will it work? - Greorghe Lanescu