Jump to content

Rnadomize a variable inside a function

Recommended Posts



I want to randomize a variable defined in a function. The function is inside a package.


I tried declaring a class inside the package and taking the instance of that class in the function.

But that didnt work out as the object needs to be static.


I tried randomization() function, but the problem is the variable "k" can only have 2 value ie (5,9).


function foo()

 int k;

 void'(randomize(k)) with {k==5;k==9;});  // I am getting randomization failure in this case.



Let me know how can this be resolved.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...