0

Hello,

I need to implement the following situation in C++:

I have a counter which I want to increment with a certain probability.

I am giving a pseudo code which will clear:

counter = 0;

prob = 0.5;

for i <- 1 to 100

if(prob) // want to increment the counter with probability=0.5

counter++;

else

// do nothing

Your help is highly appreciated!!!