Generating a random number

 

Hey Guys,

Wondering if someone can help me on this:

In my code i try to generagte a random number and store it as a variable like this:

rannum=MathRand();

Print ("A: ", rannum);

<I then have lots of other code >

Later on i try to print that exact same number in another print statement...

Print ("B: ", rannum);

Results:

A= 1485

B= 2084

The problem is, I get 2 different random numbers. How can i generate the first number store it into a variable and then use it again later without regenerating it?

 

You need to protect your random number generator inside a conditional-if statement


if(counter==0)

{

//generate random number here

counter =1

}