`p`

So, instead of using 2 which gives you a straight 50:50, you need to use the value of

`p`

to bias your results. Since `p`

is a floating point value between 0 and 1 and `rand`

always returns an integer, you are going to have to get sneaky.I'd start by doing two tests: p = 0 (in which case return 0) and p = 1 (in which case return 1). If they both fail, then generate a random number and multiply it by p. If the result is greater than half the maximum value

`rand`

can return in your system then return a 1, otherwise return a 0.But this is your homework, not mine - so I'll give you no code!